Use std::io::IsTerminal instead of atty crate (#2066)
This commit is contained in:
parent
178d4e2190
commit
63ad7cc176
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -517,7 +517,6 @@ name = "just"
|
||||
version = "1.26.0"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"blake3",
|
||||
"camino",
|
||||
"clap 4.5.4",
|
||||
|
@ -19,7 +19,6 @@ members = [".", "crates/*"]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.12.0"
|
||||
atty = "0.2.0"
|
||||
blake3 = { version = "1.5.0", features = ["rayon", "mmap"] }
|
||||
camino = "1.0.4"
|
||||
clap = { version = "4.0.0", features = ["env", "wrap_help"] }
|
||||
|
20
src/color.rs
20
src/color.rs
@ -1,14 +1,14 @@
|
||||
use {
|
||||
super::*,
|
||||
ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix},
|
||||
atty::Stream,
|
||||
std::io::{self, IsTerminal},
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub(crate) struct Color {
|
||||
use_color: UseColor,
|
||||
atty: bool,
|
||||
is_terminal: bool,
|
||||
style: Style,
|
||||
use_color: UseColor,
|
||||
}
|
||||
|
||||
impl Color {
|
||||
@ -16,9 +16,9 @@ impl Color {
|
||||
Self { style, ..self }
|
||||
}
|
||||
|
||||
fn redirect(self, stream: Stream) -> Self {
|
||||
fn redirect(self, stream: impl IsTerminal) -> Self {
|
||||
Self {
|
||||
atty: atty::is(stream),
|
||||
is_terminal: stream.is_terminal(),
|
||||
..self
|
||||
}
|
||||
}
|
||||
@ -53,11 +53,11 @@ impl Color {
|
||||
}
|
||||
|
||||
pub(crate) fn stderr(self) -> Self {
|
||||
self.redirect(Stream::Stderr)
|
||||
self.redirect(io::stderr())
|
||||
}
|
||||
|
||||
pub(crate) fn stdout(self) -> Self {
|
||||
self.redirect(Stream::Stdout)
|
||||
self.redirect(io::stdout())
|
||||
}
|
||||
|
||||
pub(crate) fn context(self) -> Self {
|
||||
@ -116,7 +116,7 @@ impl Color {
|
||||
match self.use_color {
|
||||
UseColor::Always => true,
|
||||
UseColor::Never => false,
|
||||
UseColor::Auto => self.atty,
|
||||
UseColor::Auto => self.is_terminal,
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,9 +136,9 @@ impl Color {
|
||||
impl Default for Color {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
use_color: UseColor::Auto,
|
||||
atty: false,
|
||||
is_terminal: false,
|
||||
style: Style::new(),
|
||||
use_color: UseColor::Auto,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user