alexeyraspopov / picocolors

The tiniest and the fastest library for terminal output formatting with ANSI colors
ISC License
1.34k stars 44 forks source link

Request: Check for `--force-color` instead of `--color` #42

Closed anko closed 2 years ago

anko commented 2 years ago

Existing programs that want to migrate to this library may have a --color option that takes an argument, such as --color none or --color auto. The natural implementation of --color auto would be to simply do nothing and let picocolors decide if colors should be on. But because the --color flag is present in process.argv (even though its intention was different), this line will always force colors on, so implementing --color auto is impossible. Unless you do the detection yourself, which kind of defeats the point.

The env variables are already called NO_COLOR and FORCE_COLOR; I think it would be least surprising for the options to also be --no-color and --force-color. Those are pretty unambiguous.

ai commented 2 years ago

Changing the argument will break CLI tools which use --color for now. For instance, Stylelint.

Many UNIX tools like ls or grep doesn’t have --force-color argument too. They use --color and --color=false/--color=auto.

Other color libraries, for instance, chalk doesn’t use --force-color as well https://github.com/chalk/supports-color/blob/main/index.js

anko commented 2 years ago

It's an entrenched enough habit that it's effectively a standard then. Better leave it that way.