Support global toggle via env variable
mackwic opened this issue · comments
Hi @ogham !
I am the author of colored, a library highly influenced by yours, ansi_term
. So, thanks for that. :)
One of the biggest feedback I got when publishing the release notes, was about an option for the user to turn on or off globally the coloring, so I think I should report to you too.
I was planning to use the RUST_NOCOLOR
and RUST_FORCECOLOR
env variable for that, I think it would be great if both our lib used the same variable names. What do you think ? I have no strong feeling on anything, I just want the user experience to be superb, so don't hesitate
linking to Colored tracking issue: colored-rs/colored#2
Hi there!
I wrote this crate for adding colours to exa, and soon after, I did have to add a global colours-off toggle: you're right about it being a common request. However, I'm not sure whether this toggle belongs in the colours crate itself, or whether it should be a property of some kind of 'terminal' type that we still need to bikeshed out. Looks like there's a discussion on the forums going on; I'll post my main reply there (and will keep this issue open, to see how things turn out)
Please don't process environment variables inside of ansi-term. I think it makes sense to handle policy for color enable/disable in a higher-level library, and produce a Style (which might be plain); that policy will be harder to write if ansi-term itself implements its own policy. (For instance, a program might have its own --color=always
option that it wants to override the lower-level policy with.)
@joshtriplett this could be a default behavior with a feature flag on the build for those who want to customize the behavior.
I thought about this a bit and decided to not have it as a feature — I feel like this crate is at the wrong level for decisions like that to be made. exa handles this by using #[derive(Default)]
with a struct full of Style
s to make a colour theme with no colours in it, and it can do so because it picks how to switch colours on/off.