pixi
pixi copied to clipboard
Option '--color always' is not working as expected.
Checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pixi, using
pixi --version.
Reproducible example
pixi --color always help add | less
pixi --color always help add > capture.out
Issue description
I was using a pager (less) to display the output of some Pixi help and noticed that colors are always removed if the output of a Pixi command is sent through a pipe. Even if the option --color always is used. Also happens if I capture the output in a file with the tee command.
As a workaround I currently prefix every pixi command with unbuffer (from the Linux package expect) if I want to ensure colored output.
Version info:
$ pixi --version
pixi 0.28.2
$ uname -mro
6.10.6-200.fc40.x86_64 x86_64 GNU/Linux
Expected behavior
I think the optimal behavior would be this:
If the output is sent to stdout (not to a pipe) and does not fit the screen then automatically display the output with a pager (including colors if --color always is used or no NO_COLOR environment variable is set). And maybe have an option --no-pager to explicitly disable this behavior. You could have a look at how UV implements this (e.g. uv help run, uv help --no-pager run, NO_COLOR=1 uv help run, uv help --color never run).
It seems like specifically the help subcommand is an issue. Other commands seem to work fine, try pixi task list.
clap handles the help command for us. Ill try checking if we can influence that.