Support `FORCE_COLOR` and `NO_COLOR` environment variables
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
It would be great if the FORCE_COLOR and NO_COLOR environment variables could be used during calls to click.echo/click.secho to determine the default preference for colouring of stdout/stderr when an explicit preference for outputting colour is not set.
It appears that currently, click simply inspects whether the output stream considers itself to be a physical TTY. This is problematic on build systems such as GitLab or Jenkins or GitHub Actions, as logs that could be output in colour will not be since the output stream is still technically a file.
Supporting this would allow simpler catering for outputs that are designed to help visually impaired users when viewing automated build outputs, but may have other applications as well.
These environment variables are a good candidate to be used, because the Python interpreter already considers these specific variables, and other libraries such as colorlog also respect this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the click.echo and click.secho color-preference handling, then compare how Python and colorlog interpret FORCE_COLOR and NO_COLOR. Done means those variables determine the default stdout/stderr coloring only when no explicit color preference is supplied, with tests covering the relevant combinations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100