mirror of https://github.com/zkat/miette.git
Switch out `atty` for `is-terminal`
This commit is contained in:
parent
ed486c959d
commit
3f30d76505
10
Cargo.toml
10
Cargo.toml
|
|
@ -19,11 +19,11 @@ once_cell = "1.8.0"
|
|||
unicode-width = "0.1.9"
|
||||
|
||||
owo-colors = { version = "3.0.0", optional = true }
|
||||
atty = { version = "0.2.14", optional = true }
|
||||
is-terminal = { version = "0.4.1", optional = true }
|
||||
textwrap = { version = "0.15.0", optional = true }
|
||||
supports-hyperlinks = { version = "1.1.0", optional = true }
|
||||
supports-color = { version = "1.1.1", optional = true }
|
||||
supports-unicode = { version = "1.0.0", optional = true }
|
||||
supports-hyperlinks = { git = "https://github.com/Porges/supports-hyperlinks", optional = true }
|
||||
supports-color = { git = "https://github.com/zkat/supports-color", optional = true }
|
||||
supports-unicode = { git = "https://github.com/Porges/supports-unicode", optional = true }
|
||||
backtrace = { version = "0.3.61", optional = true }
|
||||
terminal_size = { version = "0.1.17", optional = true }
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ lazy_static = "1.4"
|
|||
default = []
|
||||
fancy-no-backtrace = [
|
||||
"owo-colors",
|
||||
"atty",
|
||||
"is-terminal",
|
||||
"textwrap",
|
||||
"terminal_size",
|
||||
"supports-hyperlinks",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use std::fmt;
|
||||
|
||||
use atty::Stream;
|
||||
|
||||
use crate::protocol::Diagnostic;
|
||||
use crate::GraphicalReportHandler;
|
||||
use crate::GraphicalTheme;
|
||||
|
|
@ -193,12 +191,12 @@ impl MietteHandlerOpts {
|
|||
let characters = match self.unicode {
|
||||
Some(true) => ThemeCharacters::unicode(),
|
||||
Some(false) => ThemeCharacters::ascii(),
|
||||
None if supports_unicode::on(Stream::Stderr) => ThemeCharacters::unicode(),
|
||||
None if supports_unicode::on(&std::io::stderr()) => ThemeCharacters::unicode(),
|
||||
None => ThemeCharacters::ascii(),
|
||||
};
|
||||
let styles = if self.color == Some(false) {
|
||||
ThemeStyles::none()
|
||||
} else if let Some(color) = supports_color::on(Stream::Stderr) {
|
||||
} else if let Some(color) = supports_color::on(supports_color::Stream::Stderr) {
|
||||
match self.rgb_colors {
|
||||
RgbColors::Always => ThemeStyles::rgb(),
|
||||
RgbColors::Preferred if color.has_16m => ThemeStyles::rgb(),
|
||||
|
|
@ -257,7 +255,7 @@ impl MietteHandlerOpts {
|
|||
if let Some(linkify) = self.linkify {
|
||||
linkify
|
||||
} else {
|
||||
supports_hyperlinks::on(Stream::Stderr)
|
||||
supports_hyperlinks::on(&std::io::stderr())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use atty::Stream;
|
||||
use is_terminal::IsTerminal;
|
||||
use owo_colors::Style;
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,9 @@ impl GraphicalTheme {
|
|||
impl Default for GraphicalTheme {
|
||||
fn default() -> Self {
|
||||
match std::env::var("NO_COLOR") {
|
||||
_ if !atty::is(Stream::Stdout) || !atty::is(Stream::Stderr) => Self::ascii(),
|
||||
_ if !std::io::stdout().is_terminal() || !std::io::stderr().is_terminal() => {
|
||||
Self::ascii()
|
||||
}
|
||||
Ok(string) if string != "0" => Self::unicode_nocolor(),
|
||||
_ => Self::unicode(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue