1
1
mirror of https://github.com/casey/just.git synced 2024-11-23 02:44:56 +03:00

Use std::io::IsTerminal instead of atty crate (#2066)

This commit is contained in:
Casey Rodarmor 2024-05-20 16:42:15 -07:00 committed by GitHub
parent 178d4e2190
commit 63ad7cc176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 12 deletions

1
Cargo.lock generated
View File

@ -517,7 +517,6 @@ name = "just"
version = "1.26.0"
dependencies = [
"ansi_term",
"atty",
"blake3",
"camino",
"clap 4.5.4",

View File

@ -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"] }

View File

@ -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,
}
}
}