From 1b5b1fb66ad50dbbae78f80dc133926ffcfa43a6 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Wed, 1 Nov 2023 07:42:46 -0700 Subject: [PATCH] chore(deps): Remove usages of atty (#18985) Turns out this is in the stdlib now. Replaces: #18966 Signed-off-by: Jesse Szwedko --- Cargo.lock | 2 -- Cargo.toml | 1 - src/cli.rs | 5 ++++- src/test_util/mod.rs | 5 ++++- vdev/Cargo.toml | 1 - vdev/src/util.rs | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd8c4b1f7897e..3d154bc56a825 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9807,7 +9807,6 @@ name = "vdev" version = "0.1.0" dependencies = [ "anyhow", - "atty", "cached", "chrono", "clap 4.4.7", @@ -9857,7 +9856,6 @@ dependencies = [ "async-nats", "async-stream", "async-trait", - "atty", "aws-config", "aws-credential-types", "aws-sdk-cloudwatch", diff --git a/Cargo.toml b/Cargo.toml index ab21f74184ce2..287624f94bf50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -332,7 +332,6 @@ mlua = { version = "0.9.1", default-features = false, features = ["lua54", "send windows-service = "0.6.0" [target.'cfg(unix)'.dependencies] -atty = { version = "0.2.14", default-features = false } nix = { version = "0.26.2", default-features = false, features = ["socket", "signal"] } [build-dependencies] diff --git a/src/cli.rs b/src/cli.rs index 794ca3ade12e0..54ec9cbb747c4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -333,7 +333,10 @@ impl Color { pub fn use_color(&self) -> bool { match self { #[cfg(unix)] - Color::Auto => atty::is(atty::Stream::Stdout), + Color::Auto => { + use std::io::IsTerminal; + std::io::stdout().is_terminal() + } #[cfg(windows)] Color::Auto => false, // ANSI colors are not supported by cmd.exe Color::Always => true, diff --git a/src/test_util/mod.rs b/src/test_util/mod.rs index ff3cc3d5fbee8..3b4e705e67f3c 100644 --- a/src/test_util/mod.rs +++ b/src/test_util/mod.rs @@ -122,7 +122,10 @@ pub fn next_addr_v6() -> SocketAddr { pub fn trace_init() { #[cfg(unix)] - let color = atty::is(atty::Stream::Stdout); + let color = { + use std::io::IsTerminal; + std::io::stdout().is_terminal() + }; // Windows: ANSI colors are not supported by cmd.exe // Color is false for everything except unix. #[cfg(not(unix))] diff --git a/vdev/Cargo.toml b/vdev/Cargo.toml index 4264cec8ebcd8..f11dd3200adde 100644 --- a/vdev/Cargo.toml +++ b/vdev/Cargo.toml @@ -9,7 +9,6 @@ publish = false [dependencies] anyhow = "1.0.75" -atty = "0.2.14" cached = "0.46.0" chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] } clap = { version = "4.4.7", features = ["derive"] } diff --git a/vdev/src/util.rs b/vdev/src/util.rs index 306ccd9c1c1b8..e559b20f496dd 100644 --- a/vdev/src/util.rs +++ b/vdev/src/util.rs @@ -1,4 +1,5 @@ use std::ffi::{OsStr, OsString}; +use std::io::IsTerminal; use std::process::{Command, Output}; use std::{collections::BTreeMap, fmt::Debug, fs, io::ErrorKind, path::Path}; @@ -7,7 +8,7 @@ use once_cell::sync::Lazy; use serde::Deserialize; use serde_json::Value; -pub static IS_A_TTY: Lazy = Lazy::new(|| atty::is(atty::Stream::Stdout)); +pub static IS_A_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); #[derive(Deserialize)] pub struct CargoTomlPackage {