From 8b03c49d0eeba213108ba12cc91308e7bff7c39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Thu, 22 Sep 2022 23:54:44 +0200 Subject: [PATCH] chore: replace atty with is-terminal --- Cargo.lock | 31 ++++++++++++++++++++++++++++--- Cargo.toml | 4 ++-- src/output/fmt.rs | 11 +++++------ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3002d6818bb4..8312381dc98f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -112,12 +112,12 @@ dependencies = [ name = "clap" version = "4.0.0-rc.2" dependencies = [ - "atty", "backtrace", "bitflags", "clap_derive", "clap_lex", "humantime", + "is-terminal", "once_cell", "rustversion", "shlex", @@ -401,6 +401,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "humantime" version = "2.1.0" @@ -432,6 +441,22 @@ name = "io-lifetimes" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d508111813f9af3afd2f92758f77e4ed2cc9371b642112c6a48d22eb73105c5" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys", +] [[package]] name = "is_executable" @@ -544,7 +569,7 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 771c5c96d57d..be9729e621d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ unstable-doc = ["derive", "cargo", "wrap_help", "env", "unicode", "string", "uns # Used in default std = [] # support for no_std in a backwards-compatible way -color = ["dep:atty", "dep:termcolor"] +color = ["dep:is-terminal", "dep:termcolor"] help = [] usage = [] error-context = [] @@ -96,7 +96,7 @@ clap_lex = { path = "./clap_lex", version = "0.3.0" } bitflags = "1.2" unicase = { version = "2.6", optional = true } strsim = { version = "0.10", optional = true } -atty = { version = "0.2", optional = true } +is-terminal = { version = "0.3", optional = true } termcolor = { version = "1.1.1", optional = true } terminal_size = { version = "0.2.1", optional = true } backtrace = { version = "0.3", optional = true } diff --git a/src/output/fmt.rs b/src/output/fmt.rs index ad0c22e6137c..73595c7d4d58 100644 --- a/src/output/fmt.rs +++ b/src/output/fmt.rs @@ -82,10 +82,9 @@ impl std::fmt::Display for Colorizer { #[cfg(feature = "color")] fn is_a_tty(stream: Stream) -> bool { - let stream = match stream { - Stream::Stdout => atty::Stream::Stdout, - Stream::Stderr => atty::Stream::Stderr, - }; - - atty::is(stream) + use is_terminal::IsTerminal; + match stream { + Stream::Stdout => std::io::stdout().is_terminal(), + Stream::Stderr => std::io::stderr().is_terminal(), + } }