diff --git a/Cargo.lock b/Cargo.lock index 0ed288c905..fbb5838433 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,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", ] @@ -515,6 +515,27 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -609,6 +630,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 = "hex" version = "0.4.3" @@ -678,6 +708,28 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" +[[package]] +name = "io-lifetimes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d367024b3f3414d8e01f437f704f41a9f64ab36f9067fa73e526ad4c763c87" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys 0.42.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -716,7 +768,6 @@ name = "jujutsu" version = "0.5.1" dependencies = [ "assert_cmd", - "atty", "chrono", "clap 4.0.26", "clap_complete", @@ -729,6 +780,7 @@ dependencies = [ "git2", "hex", "insta", + "is-terminal", "itertools", "jujutsu-lib", "libc", @@ -844,6 +896,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "lock_api" version = "0.4.9" @@ -949,7 +1007,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -1374,6 +1432,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustix" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "ryu" version = "1.0.11" diff --git a/Cargo.toml b/Cargo.toml index 5a3de5cc00..2bedce2332 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ harness = false members = ["lib"] [dependencies] -atty = "0.2.14" chrono = { version = "0.4.23", default-features = false, features = ["std", "clock"] } clap = { version = "4.0.26", features = ["derive", "deprecated"] } clap_complete = "4.0.5" @@ -44,6 +43,7 @@ crossterm = { version = "0.25", default-features = false } dirs = "4.0.0" git2 = "0.15.0" hex = "0.4.3" +is-terminal = "0.4.0" itertools = "0.10.5" jujutsu-lib = { version = "=0.5.1", path = "lib"} once_cell = "1.15.0" diff --git a/src/ui.rs b/src/ui.rs index 3eeb53d9e8..e9a957c1ba 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -17,7 +17,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::{fmt, io}; -use atty::Stream; +use is_terminal::IsTerminal; use jujutsu_lib::settings::UserSettings; use crate::formatter::{Formatter, FormatterFactory}; @@ -80,7 +80,7 @@ fn use_color(choice: ColorChoice) -> bool { match choice { ColorChoice::Always => true, ColorChoice::Never => false, - ColorChoice::Auto => atty::is(Stream::Stdout), + ColorChoice::Auto => io::stdout().is_terminal(), } } @@ -154,7 +154,7 @@ impl Ui { /// Whether continuous feedback should be displayed for long-running /// operations pub fn use_progress_indicator(&self) -> bool { - self.settings().use_progress_indicator() && atty::is(Stream::Stdout) + self.settings().use_progress_indicator() && io::stdout().is_terminal() } pub fn write(&mut self, text: &str) -> io::Result<()> { @@ -208,7 +208,7 @@ impl Ui { } pub fn prompt(&mut self, prompt: &str) -> io::Result { - if !atty::is(Stream::Stdout) { + if !io::stdout().is_terminal() { return Err(io::Error::new( io::ErrorKind::Unsupported, "Cannot prompt for input since the output is not connected to a terminal", @@ -222,7 +222,7 @@ impl Ui { } pub fn prompt_password(&mut self, prompt: &str) -> io::Result { - if !atty::is(Stream::Stdout) { + if !io::stdout().is_terminal() { return Err(io::Error::new( io::ErrorKind::Unsupported, "Cannot prompt for input since the output is not connected to a terminal",