New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to force color output #8132
Comments
I decided to go ahead with the PR (see #8135), because it's a nice way to get my feet wet with the pip code base. Hope that's ok. Feel free to close if you don't want this feature. |
Using pip in the Windows 10 PowerShell activates the color output. But error messages are printed in dark-red on dark-blue, making them nearly illegible to me. So this option would at least circumvent this problem. |
@CloudbusterOhio Disabling color output is already available using pip's |
Looks like the |
Merging this into the other issue. |
What's the problem this feature will solve?
Sometimes you want color output when the output stream is not a tty. For example, GitHub Actions does not currently provide a tty to jobs, see actions/runner#241.
Describe the solution you'd like
Add a new option
--color=WHEN
.WHEN
can bealways
,auto
, ornever
:always
: Force color outputauto
: Enable color output if output is a tty (default behavior)never
: Do not color output.With this change, the existing option
--no-color
becomes a shorthand for--color=never
.For example, on a CI system which does not provide a tty, you can invoke
pip --color=always
to enable color output explicitly.Alternative Solutions
I am not aware of an alternative solution. You can work around this by allocating a pseudoterminal explicitly, for example using pyinvoke with
pty=True
.Update: pip already enables color output when
TERM=ANSI
is passed in the environment. AFAICS this behavior is undocumented.Additional context
The proposed design comes from the ls(1) command of GNU coreutils. Additionally, the
ls
option allows passing--color
without an argument, in which caseWHEN
defaults toalways
.Happy to provide a PR, if there is interest in this. 🐾
The text was updated successfully, but these errors were encountered: