Skip to content

Commit

Permalink
Replace the unmaintained "atty" crate with "is-terminal"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
primeos-work committed Jul 31, 2023
1 parent 102620e commit fd4a11a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
28 changes: 4 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -27,7 +27,6 @@ maintenance = { status = "passively-maintained" }
anyhow = "1"
aquamarine = "0.3"
ascii_table = "4"
atty = "0.2"
bytesize = "1"
chrono = "0.4"
clap = { version = "4", features = ["cargo"] }
Expand All @@ -48,6 +47,7 @@ human-panic = "1"
humantime = "2"
indicatif = "0.17"
indoc = "2"
is-terminal = "0.4"
itertools = "0.11"
lazy_static = "1"
log = "0.4"
Expand Down
3 changes: 2 additions & 1 deletion src/commands/util.rs
Expand Up @@ -19,6 +19,7 @@ use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
use clap::ArgMatches;
use is_terminal::IsTerminal;
use itertools::Itertools;
use regex::Regex;
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -202,7 +203,7 @@ pub fn display_data<D: Display>(
.map_err(Error::from)
.and_then(|t| String::from_utf8(t).map_err(Error::from))
.and_then(|text| writeln!(lock, "{text}").map_err(Error::from))
} else if atty::is(atty::Stream::Stdout) {
} else if std::io::stdout().is_terminal() {
let mut ascii_table = ascii_table::AsciiTable::default();
ascii_table.set_max_width(
terminal_size::terminal_size()
Expand Down
3 changes: 2 additions & 1 deletion src/util/mod.rs
Expand Up @@ -8,6 +8,7 @@
// SPDX-License-Identifier: EPL-2.0
//

use is_terminal::IsTerminal;
use serde::Deserialize;
use serde::Serialize;

Expand Down Expand Up @@ -47,5 +48,5 @@ pub mod parser;
pub mod progress;

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

0 comments on commit fd4a11a

Please sign in to comment.