From 7310d00cfc36fb44854abdbaae7abc9a0088a9ed Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Mon, 30 Oct 2023 15:42:59 -0700 Subject: [PATCH] chore(deps): Remove usages of atty 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 06714ca4c8f0b..d3c89833585c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9655,7 +9655,6 @@ name = "vdev" version = "0.1.0" dependencies = [ "anyhow", - "atty", "cached", "chrono", "clap 4.4.7", @@ -9705,7 +9704,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 03c7bb28096c3..6bde42b644aeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -338,7 +338,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 {