allow CLICOLOR_FORCE env var to force CLI color output
This adds support for using the CLICOLOR_FORCE environment variable to force color output in Linux even when a tty is not used, mimicking behavior in CMake and other tools. The primary intent is to allow color to be output when cppcheck is run in CI, for example.
Thanks for your contribution. Please add a unit test for this.
Shouldn't this implement NO_COLOR as well?
hmm I am not sure if a unit test would be possible. not if getenv is cached. maybe you want to uncache it it testing somehow. or another alternative is to write a test in cppcheck/test/cli/test-other.py
You could add a line in the releasenotes.txt also. And before we merge it it would not hurt if I add a ticket in trac.
hmm I am not sure if a unit test would be possible. not if getenv is cached. it might be better to write a test in cppcheck/test/cli/test-other.py
That's actually what I meant. It was still early. 😴
Shouldn't this implement
NO_COLORas well?
According to the full linked "proposal", yes, however most of the other tools that support CLICOLOR_FORCE don't actually support NO_COLOR (it seems far less useful, imo). I'm happy to modify the update if you prefer, though.
According to the full linked "proposal", yes, however most of the other tools that support
CLICOLOR_FORCEdon't actually supportNO_COLOR(it seems far less useful, imo). I'm happy to modify the update if you prefer, though.
I would prefer if you would do both while you are at it.
I think your code and testing looks good.
Adding the NO_COLOR sounds easy technically, I am in favor of adding it also :-). But I am not sure how you would add the test for it - ideally the test would provide a tty terminal right?
Thanks. I think I figured out a decent way to test using tty, let me know if you'd prefer to omit that.
I still want to take a look this weekend. Something seems off to me but I cannot tell what.
I still want to take a look this weekend. Something seems off to me but I cannot tell what.
Already commented on the "off" thing. Still need to take a look at the Python stuff.
Sorry the review took so long.