From 4e8e04591daf17bd0282b262b2e94869451cd5be Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 1 Jan 2024 16:12:21 -0500 Subject: switch to is-terminal --- Cargo.lock | 28 ++++------------------------ Cargo.toml | 2 +- src/edit.rs | 4 +++- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18f96b0..2dad6e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,17 +132,6 @@ dependencies = [ "syn", ] -[[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 = "1.1.0" @@ -692,15 +681,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[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.2" @@ -848,7 +828,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "libc", "windows-sys 0.48.0", ] @@ -865,7 +845,7 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "io-lifetimes", "rustix", "windows-sys 0.48.0", @@ -1095,7 +1075,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "libc", ] @@ -1316,7 +1296,6 @@ dependencies = [ "argon2", "arrayvec", "async-trait", - "atty", "base32", "base64", "block-padding", @@ -1333,6 +1312,7 @@ dependencies = [ "hkdf", "hmac", "humantime", + "is-terminal", "libc", "log", "nix", diff --git a/Cargo.toml b/Cargo.toml index a57be0d..b57a208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ anyhow = "1.0.72" argon2 = "0.5.1" arrayvec = "0.7.4" async-trait = "0.1.71" -atty="0.2.*" base32 = "0.4.0" base64 = "0.21.2" block-padding = "0.3.3" @@ -65,6 +64,7 @@ zeroize = "1.6.0" copypasta = "0.8.2" rmpv = "1.0.0" tokio-tungstenite = { version = "0.19.0", features = ["rustls-tls-native-roots"] } +is-terminal = "0.4.7" [package.metadata.deb] depends = "pinentry" diff --git a/src/edit.rs b/src/edit.rs index 4862c0b..360f31f 100644 --- a/src/edit.rs +++ b/src/edit.rs @@ -2,8 +2,10 @@ use crate::prelude::*; use std::io::{Read as _, Write as _}; +use is_terminal::IsTerminal as _; + pub fn edit(contents: &str, help: &str) -> Result { - if !atty::is(atty::Stream::Stdin) { + if !std::io::stdin().is_terminal() { // directly read from piped content return match std::io::read_to_string(std::io::stdin()) { Err(e) => Err(Error::FailedToReadFromStdin { err: e }), -- cgit v1.2.3-54-g00ecf