-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support NO_COLOR environment variable #2207
Comments
Duplicate of #1498. While I understand the intention of the proposal, it's not clear that it's an actual accepted standard (there are plenty of other env vars across projects), or the correct thing to do. See linked discussions on the previous issue. For example, Click doesn't provide a if __name__ == "__main__":
color = os.environ.get("NO_COLOR")
color = color in {"1", "true"} if color is not None else None
cli(color=color) I did see that Rich implements this, but that alone isn't a convincing reason for it. |
Sorry, I should have found the prior issue. It really doesn’t need to be supported directly, I guess, but easy to implement support without logic around every style or secho. It may be already. To me, ideally there should be a simple pattern for support or direct support. And thank you. This library has made me happy and more productive for so long. |
No problem. The color parameter shown above will tell Click to not output color codes. So if you want to support that env var, reading it and setting the parameter will do the right thing. |
If you're interested @mmessmore, I've created a ready-to-use |
Oh, thank you. That’s great. |
Support disabling color output globally using the NO_COLOR environment variable as specified here: https://no-color.org/
In particular it would be useful for CI output and users who dislike stylized output for my CLIs.
The text was updated successfully, but these errors were encountered: