colored-rs / colored

(Rust) Coloring terminal so simple you already know how to do it !
Mozilla Public License 2.0
1.73k stars 83 forks source link

Use is_terminal from std lib? #141

Closed jcamiel closed 1 year ago

jcamiel commented 1 year ago

Hi, In Rust 1.70, is_terminal is available on std::io::stdout()/stderr()/stdin(), maybe this is an opportunity to remove the atty dependency?

In /colored/src/control.rs instead of:

ShouldColorize {
            clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true)
                && atty::is(atty::Stream::Stdout),

The code can be now:

ShouldColorize {
            clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true)
                && std::io::stdout().is_terminal(),

I can make a PR if needed!

Thanks,

jcamiel commented 1 year ago

Ah sorry, I didn't check PR (#134), fill free to close mine!

hwittenborn commented 1 year ago

This is actually being discussed in https://github.com/colored-rs/colored/pull/122#issuecomment-1618254492 as well, an MSRV just needs to be decided on before figuring out if a crate or the stdlib will be used.

Feel free to track the issue linked in that PR for any updates :)