#cli-color #terminal #no-color

should-color

Determine whether output should use colors or not

8 releases (4 breaking)

0.5.2 Sep 22, 2022
0.5.1 Sep 14, 2022
0.4.0 Sep 6, 2022
0.3.0 Sep 5, 2022
0.1.0 Sep 5, 2022

#609 in Command-line interface

Download history 5/week @ 2024-02-22 6/week @ 2024-02-29 197/week @ 2024-03-07

208 downloads per month
Used in texfmt

MIT license

21KB
150 lines

should-color

Determine whether output should use colors or not.

crates.io docs.rs GitHub GitHub Workflow Status Dependencies status MIT license

The should-color crate helps determine the color choice for an application output based on the command line arguments and environment variables.

The resulting color choice is determined by taking into account, in order of priority from higher to lower, the following settings:

  • CLICOLOR_FORCE environment variable (requires clicolor_force feature),
  • explicit user preference (for instance command line arguments),
  • CLICOLOR environment variable (requires clicolor feature),
  • NO_COLOR environment variable (requires no_color feature),
  • application default choice.

Please refer to the documentation for more details on the resolution process.

Alternatives and comparison

Dependencies

~0.2–0.8MB
~13K SLoC