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
Respect NO_COLOR and FORCE_COLOR #2
Comments
From all the projects (apart from pytest where you've added it) I've checked out locally only https://github.com/qix-/better-exceptions uses it, but requires it to be "1" then - unlike pytest where any value forces color (similar to |
Yeah, There's also a PR (nearly one year old!) for Colorama (tartley/colorama#230) that adds both, and checks for presence, regardless of its value. I think that makes sense, to use the same way of checking for Thanks! |
AIUI this change means that I ask because I maintain a (proprietary) library using termcolor that allows users to:
With this change, I can no longer explicitly enable color (without patching Perhaps |
Yes, that's correct, The idea is the person running a command-line tool has an easy way to disable colour output across all tools, and they may not be able to change the tool code itself.
Then we have a bit of an "conflict":
Yeah, that might actually be a reasonable way to do it: if you really don't want import os
import termcolor
del os.environ["NO_COLOR"]
termcolor.cprint("hi", "green") |
I think it's a good idea to respect However, I do think there's value in allowing the developer full control over color if they want it. For example:
I'm sure there are other cases, too, where it's useful for coloration to be "pure", in the sense that its behaviour is consistent regardless of the user's environment.
That said, I appreciate that termcolor is ultimately open-source and provided for free! If you prefer to go a different route, that's entirely your perogative. |
Now I re-read https://no-color.org/ I see it's been updated to clarify some things:
So I think this supports your suggestion of a keyword argument 👍 Now the really difficult bit is finding a name for the keyword argument! Do you have any ideas? Do any other libraries at https://no-color.org/ have such an option, and what do they call it? I don't think any of the Python libraries support it. |
PR #25 adds tty detection and support for the |
Please see PR #38 to add parameters to override the environment variables. |
NO_COLOR
#7FORCE_COLOR
and detect tty #25The text was updated successfully, but these errors were encountered: