Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace atty with std::io::IsTerminal #380

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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