From 69ee1738d48e978a936cab07a984812ee364f8e8 Mon Sep 17 00:00:00 2001 From: Lena <126529524+acuteenvy@users.noreply.github.com> Date: Tue, 17 Oct 2023 00:31:58 +0200 Subject: [PATCH] Remove dependency on `atty` and use `std::io::IsTerminal` instead --- Cargo.lock | 23 +---------------------- Cargo.toml | 2 -- src/options.rs | 4 ++-- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f84aca4..23e5656 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,17 +117,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "0.1.8" @@ -464,15 +453,6 @@ dependencies = [ "ahash 0.8.3", ] -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.3" @@ -486,7 +466,6 @@ dependencies = [ "anyhow", "approx", "assert_cmd", - "atty", "clap", "clap_complete", "colored", @@ -535,7 +514,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "rustix", "windows-sys 0.48.0", ] diff --git a/Cargo.toml b/Cargo.toml index 83bbbe2..5c776b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ windows_process_extensions_main_thread_handle = [] colored = "2.0" indicatif = "=0.17.4" statistical = "1.0" -atty = "0.2" csv = "1.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -61,7 +60,6 @@ tempfile = "3.3" [build-dependencies] clap = "4.0.18" -atty = "0.2" clap_complete = "4.2.1" [profile.release] diff --git a/src/options.rs b/src/options.rs index a7f820e..2f83889 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,10 +1,10 @@ use std::fs::File; +use std::io::IsTerminal; use std::path::PathBuf; use std::process::{Command, Stdio}; use std::{cmp, env, fmt, io}; use anyhow::ensure; -use atty::Stream; use clap::ArgMatches; use crate::command::Commands; @@ -333,7 +333,7 @@ impl Options { Some("none") => OutputStyleOption::Disabled, _ => { if options.command_output_policy == CommandOutputPolicy::Inherit - || !atty::is(Stream::Stdout) + || !io::stdout().is_terminal() { OutputStyleOption::Basic } else if env::var_os("TERM")