Skip to content

Commit

Permalink
Merge pull request #4249 from jcgruenhage/replace-atty
Browse files Browse the repository at this point in the history
chore: replace atty with is-terminal
  • Loading branch information
epage authored Nov 24, 2022
2 parents 789bfd6 + aaac3c4 commit fb1d960
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 21 deletions.
134 changes: 121 additions & 13 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ unstable-doc = ["derive", "cargo", "wrap_help", "env", "unicode", "string", "uns

# Used in default
std = [] # support for no_std in a backwards-compatible way
color = ["dep:atty", "dep:termcolor"]
color = ["dep:is-terminal", "dep:termcolor"]
help = []
usage = []
error-context = []
Expand Down Expand Up @@ -96,7 +96,7 @@ clap_lex = { path = "./clap_lex", version = "0.3.0" }
bitflags = "1.2"
unicase = { version = "2.6", optional = true }
strsim = { version = "0.10", optional = true }
atty = { version = "0.2", optional = true }
is-terminal = { version = "0.4", optional = true }
termcolor = { version = "1.1.1", optional = true }
terminal_size = { version = "0.2.1", optional = true }
backtrace = { version = "0.3", optional = true }
Expand Down
11 changes: 5 additions & 6 deletions src/output/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ impl std::fmt::Display for Colorizer {

#[cfg(feature = "color")]
fn is_a_tty(stream: Stream) -> bool {
let stream = match stream {
Stream::Stdout => atty::Stream::Stdout,
Stream::Stderr => atty::Stream::Stderr,
};

atty::is(stream)
use is_terminal::IsTerminal;
match stream {
Stream::Stdout => std::io::stdout().is_terminal(),
Stream::Stderr => std::io::stderr().is_terminal(),
}
}

0 comments on commit fb1d960

Please sign in to comment.