Repository navigation
support FORCE_COLOR in click.echo #558
Description
Activity
You can set
ctx.color = Trueto force color output, so it's trivial to implement this in usercode. I personally don't think this behavior should be added to Click itself, even though Click stands for reasonable defaults, I think it makes the logic too complex to easily fit in the user's head.What would also help is more example applications with this convention.
well, the chalk JS package has those 13 000 depending packages.
this (transitively) includes nearly all node.js command line applications.
but yeah: there’s no real standard for this. just check this mess
i think we have
FORCE_COLOR,CLICOLOR,CLICOLOR_FORCE,LS_COLORS,GREP_COLORS, and various--coloroptions, e.g.--color=always|auto|offin GNU tools.CLICOLOR[_FORCE]seems to be in cmake and OSX tools, as well as the most clear and intuitive way, but none of the bug reports for other libs had any impact. i’m sad for @jhasse for putting in so much work in PRs being interested, despite it being the best idea and already integrated in some tools.convenient and expected would IMHO be to have a method that automatically adds a GNU-like
--coloroption, as well as support for the whole env variable mess like supports-color does.Reacted by Jan Niklas Hassefor semantics:
FORCE_COLOR≠ 0,CLICOLOR_FORCE≠ 0,--color=alwaysforce it to be onCLICOLOR≠ 0,--color,--color=automeans autodetectionCLICOLOR=0,FORCE_COLOR=0,--color=offforce it to be offCLICOLOR_FORCE=0just means no forcing, just like it being unset
Closing this because it is closely related to the following issue.
#558Happy to review a PR if you have a proposed implementation.
uh, #558 is this issue. which one do you really mean?
Hah good catch #1090
NP. Why did you close this one though? The other one came later and contains much less information than what I researched above.
You are right, I am trying to consolidate issues on the tracker. I do appreciate the background you gave it was helpful context. I just closed this one because it had been stale for longer.
I'm not sure there is a clean way to implement this, but i'm not completely opposed to it. Happy to look at a PR if you have an idea on implementation.
OK, I just moved my stuff there then
Thanks!
- locked as resolved and limited conversation to collaborators
on Nov 13, 2020 - changed the title
[-]support FORCE_COLOR in click.echo[/-][+]support `FORCE_COLOR` in `click.echo`[/+]on Aug 3, 2025 - addedhelp outputHelp text formatting, layout, and --help renderingHelp text formatting, layout, and --help rendering
on Aug 8, 2026
FORCE_COLOR is supported by many tools (e.g. node’s popular
chalk). setting it to anything enables colors even if the autodetection wouldn’t.i think
click.echoshould support it.