fatih / color

Color package for Go (golang)
https://pkg.go.dev/github.com/fatih/color
MIT License
7.17k stars 610 forks source link

https://no-color.org/ support #136

Closed eitah closed 3 years ago

eitah commented 3 years ago

We're consumers of concourse-ci which uses this package to write to the CLI. We have an open ticket to their library to implement support for the NO_COLOR feature flag but realize they're likely dependent on changes to this lib to make that happen.

Our use case is we wish to write output from concourse-ci to a text file but the inline color codes make it tricky

More on the no-color.org movement: https://no-color.org/ The concourse feature request: https://github.com/concourse/rfcs/discussions/104 Concourse-ci.org: https://concourse-ci.org/ (unsurprisingly)

If you're short on time but want to support the feature, perhaps this is a beginner friendly ticket that I or a peer from my company could PR?

Thanks muchly! Eli

eitah commented 3 years ago

It looks like per your readme the recommended approach to suppress colors is to call isatty to get color.NoColor implemented. Fly (concourse CLI) already uses no-color in tests, so perhaps it is on their app to enable globally? Forgive the pointless ticket if so and if no-color.org single environment variable approach is too heavy-handed then.

fatih commented 3 years ago

Hi @eitah

I initially was against adding this environment variable (see: https://github.com/fatih/color/pull/92). But, now that I think, many people import this library, and people are using this without the power to change the code. This is especially true if you are using a CLI that uses fatih/color.

Hence, I reverted my decision and added support for it. Check out this PR: https://github.com/fatih/color/pull/137

eitah commented 3 years ago

Thanks! This is a great change and will be very useful for us in the future. I really appreciate the thought and care you put into this @fatih.