Skip to content

Commit fd4a11a

Browse files
committed
Replace the unmaintained "atty" crate with "is-terminal"
The "atty" crate is unmaintained [0] and also causes a low severity GitHub advisory (GHSA-g98v-hv3f-hcfr; only affects windows though) [1]: > A Pull Request with a fix has been provided over a year ago but the > maintainer seems to be unreachable. > Last release of atty was almost 3 years ago. The "clap" crate already switched to "is-terminal" [2] so we can simply use the latter without having to pull in additional dependencies. The "is-terminal" crate can also be considered a successor [3]: > This crate is derived from the atty crate with PR 51 bug fix and PR 54 > port to windows-sys applied. [0]: softprops/atty#57 [1]: https://github.com/science-computing/butido/security/dependabot/9 [2]: clap-rs/clap#4249 [3]: https://crates.io/crates/is-terminal Signed-off-by: Michael Weiss <michael.weiss@atos.net>
1 parent 102620e commit fd4a11a

4 files changed

Lines changed: 9 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ maintenance = { status = "passively-maintained" }
2727
anyhow = "1"
2828
aquamarine = "0.3"
2929
ascii_table = "4"
30-
atty = "0.2"
3130
bytesize = "1"
3231
chrono = "0.4"
3332
clap = { version = "4", features = ["cargo"] }
@@ -48,6 +47,7 @@ human-panic = "1"
4847
humantime = "2"
4948
indicatif = "0.17"
5049
indoc = "2"
50+
is-terminal = "0.4"
5151
itertools = "0.11"
5252
lazy_static = "1"
5353
log = "0.4"

src/commands/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use anyhow::Context;
1919
use anyhow::Error;
2020
use anyhow::Result;
2121
use clap::ArgMatches;
22+
use is_terminal::IsTerminal;
2223
use itertools::Itertools;
2324
use regex::Regex;
2425
use tokio_stream::StreamExt;
@@ -202,7 +203,7 @@ pub fn display_data<D: Display>(
202203
.map_err(Error::from)
203204
.and_then(|t| String::from_utf8(t).map_err(Error::from))
204205
.and_then(|text| writeln!(lock, "{text}").map_err(Error::from))
205-
} else if atty::is(atty::Stream::Stdout) {
206+
} else if std::io::stdout().is_terminal() {
206207
let mut ascii_table = ascii_table::AsciiTable::default();
207208
ascii_table.set_max_width(
208209
terminal_size::terminal_size()

src/util/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// SPDX-License-Identifier: EPL-2.0
99
//
1010

11+
use is_terminal::IsTerminal;
1112
use serde::Deserialize;
1213
use serde::Serialize;
1314

@@ -47,5 +48,5 @@ pub mod parser;
4748
pub mod progress;
4849

4950
pub fn stdout_is_pipe() -> bool {
50-
!atty::is(atty::Stream::Stdout)
51+
!std::io::stdout().is_terminal()
5152
}

0 commit comments

Comments
 (0)