Repository navigation
cmd/list: Re-enable highlighting of running containers - #494
debarshiray merged 1 commit into
Conversation
|
Build failed.
|
The rewritten Toolbox did not highlight running containers because the code uses a special table writter from 'text/tabwriter' that does not support ANSI color codes[0]. The solution used here is to use color codes on _every_ lines of the output (including headers) and make the color codes use the same number of characters. In my terminals (Tilix, GNOME Terminal) the output looks alright. [0] golang/go#35017 containers#494
4c23829 to
3b1dee8
Compare
|
Build failed.
|
|
Nice. Well done! Both GNOME Terminal and Tilix ultimately use VTE for terminal emulation; so I tried xterm to have something different, and it seems to work well there too. I will look at the actual code now. |
The Go implementation did not highlight running containers because it uses a special table writer from 'text/tabwriter' that does not support colored output [0]. The trick used here is to use ANSI SGR terminal escape sequences [1] on every line output by the table writer, including headers, and make the escape sequences use the same number of characters. eg., even though it's idiomatic to use "\033[0m" to reset the SGR attributes, such as color; each non-colored line is prefixed with "\033[0;00m" to ensure that it has the same number of characters as "\033[1;32m", which is used for bold green output. Therefore, not only are the non-colored lines wrapped in a redundant pair of ANSI SGR terminal escape sequences, they are carefully crafted to match the escape sequences for colored output. Tested on VTE and xterm. [0] golang/go#35017 [1] https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters containers#494
3b1dee8 to
61a5f51
Compare
|
Build failed.
|
|
I merged everything, except the part about supporting Podman < 2.0.0. I will leave it up to you to decide what best to do. One thing that comes to mind is whether we should be skipping the escape sequences when the output is not attached to a terminal device? People using Either way, we can use separate PRs to address them. Thanks again for working on this! |
|
Nice hack 👍 |
I think we can keep things like this. Podman overall moves very quickly forward (all supported versions of Fedora are already on V2) and only the very stable distros (Debian, CentOS, RHEL,..) will have to wait a bit. I don't think it's that important.
Yes, this is something that should be done. |
Ok, that makes sense. |
Show containers created from images that don't meet Toolbx requirements in yellow in the 'toolbox list' output. This gives users a visual hint that the container may not work as expected. The yellow color is only applied when the container is stopped. Running containers are shown in green as usual, following the coloring approach introduced in [1]. Containers with incompatible images are identified by the `com.github.containers.toolbox.image-unknown=true` label, which is set during container creation when the image fails the compatibility check. [1] containers#494 containers#1707 Signed-off-by: Dalibor Kricka <[email protected]>
Show containers created from images that don't meet Toolbx requirements in yellow in the 'toolbox list' output. This gives users a visual hint that the container may not work as expected. The yellow color is only applied when the container is stopped. Running containers are shown in green as usual, following the coloring approach introduced in [1]. Containers with incompatible images are identified by the `com.github.containers.toolbx.image-unknown=true` label, which is set during container creation when the image fails the compatibility check. [1] containers#494 containers#1707 Signed-off-by: Dalibor Kricka <[email protected]>
The rewritten Toolbox did not highlight running containers because the
code uses a special table writter from 'text/tabwriter' that does not
support ANSI color codes[0]. The solution used here is to use color
codes on every lines of the output (including headers) and make the
color codes use the same number of characters.