Skip to content

Commit

Permalink
Replace atty with std::io::IsTerminal (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin authored Oct 2, 2024
1 parent fc6d644 commit ec2daa4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
23 changes: 1 addition & 22 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ path = "src/main.rs"
[dependencies]
anyhow = "1"
app_dirs = { version = "2", package = "app_dirs2" }
atty = "0.2"
clap = { version = "4", features = ["std", "derive", "help", "usage", "cargo", "error-context", "color", "wrap_help"], default-features = false }
env_logger = { version = "0.11", optional = true }
log = "0.4"
Expand Down
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ compile_error!(
"exactly one of the features \"native-roots\", \"webpki-roots\" or \"native-tls\" must be enabled"
);

use std::{env, process};
use std::{
env,
io::{self, IsTerminal},
process,
};

use app_dirs::AppInfo;
use atty::Stream;
use clap::Parser;

mod cache;
Expand Down Expand Up @@ -258,7 +261,7 @@ fn main() {
// * NO_COLOR env var isn't set: https://no-color.org/
// * The output stream is stdout (not being piped)
ColorOptions::Auto => {
ansi_support && env::var_os("NO_COLOR").is_none() && atty::is(Stream::Stdout)
ansi_support && env::var_os("NO_COLOR").is_none() && io::stdout().is_terminal()
}
// Disable styling
ColorOptions::Never => false,
Expand Down

0 comments on commit ec2daa4

Please sign in to comment.