Skip to content

support FORCE_COLOR in click.echo #558

Description

@flying-sheep

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.echo should support it.

Activity

  1. untitaker commented on Apr 21, 2016

    @untitaker
    Contributor

    You can set ctx.color = True to 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.

  2. untitaker commented on Apr 21, 2016

    @untitaker
    Contributor

    What would also help is more example applications with this convention.

  3. flying-sheep commented on Jan 11, 2017

    @flying-sheep
    ContributorAuthor

    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 --color options, e.g. --color=always|auto|off in 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 --color option, as well as support for the whole env variable mess like supports-color does.

  4. flying-sheep commented on Jan 11, 2017

    @flying-sheep
    ContributorAuthor

    for semantics:

    • FORCE_COLOR ≠ 0, CLICOLOR_FORCE ≠ 0, --color=always force it to be on
    • CLICOLOR ≠ 0, --color, --color=auto means autodetection
    • CLICOLOR=0, FORCE_COLOR=0, --color=off force it to be off
    • CLICOLOR_FORCE=0 just means no forcing, just like it being unset
  5. jcrotts commented on May 7, 2019

    @jcrotts
    Contributor

    Closing this because it is closely related to the following issue.
    #558

    Happy to review a PR if you have a proposed implementation.

  6. flying-sheep commented on May 7, 2019

    @flying-sheep
    ContributorAuthor

    uh, #558 is this issue. which one do you really mean?

  7. jcrotts commented on May 7, 2019

    @jcrotts
    Contributor

    Hah good catch #1090

  8. flying-sheep commented on May 7, 2019

    @flying-sheep
    ContributorAuthor

    NP. Why did you close this one though? The other one came later and contains much less information than what I researched above.

  9. jcrotts commented on May 8, 2019

    @jcrotts
    Contributor

    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.

  10. flying-sheep commented on May 8, 2019

    @flying-sheep
    ContributorAuthor

    OK, I just moved my stuff there then

  11. jcrotts commented on May 8, 2019

    @jcrotts
    Contributor

    Thanks!

  12. locked as resolved and limited conversation to collaborators on Nov 13, 2020
  13. changed the title [-]support FORCE_COLOR in click.echo[/-] [+]support `FORCE_COLOR` in `click.echo`[/+] on Aug 3, 2025
  14. added
    help outputHelp text formatting, layout, and --help rendering
    on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help outputHelp text formatting, layout, and --help rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions