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

Update owo-colors #1578

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
52 changes: 24 additions & 28 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ signal-hook = { version = "0.3.15" }
directories = "4.0.1"
walkdir = { version = "2.3.2", optional = true }
tempfile = "3.3.0"
owo-colors = { version = "3.5.0", features = ["supports-colors"] }
owo-colors = { version = "4.1.0", features = ["supports-colors"] }
semver = "1.0.16"
is_ci = "1.1.1"

Expand Down
8 changes: 6 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ targets = [

[advisories]
version = 2
# FIXME: remove this if/when clap changes to is-terminal, atty is
# patched, or we migrated to an MSRV of 1.66.0.
# FIXME: remove this when color-eyre does a release of
# https://github.com/eyre-rs/eyre/pull/167
# or if atty is patched.
ignore = [
"RUSTSEC-2021-0145",
]
Expand All @@ -20,6 +21,9 @@ multiple-versions = "deny"
deny = []
skip-tree = [
{ name = "nix", version = "=0.26.4", depth = 2 },
# FIXME: remove this when color-eyre does a release of
# https://github.com/eyre-rs/eyre/pull/167
{ name = "owo-colors" },
]

[sources]
Expand Down
12 changes: 6 additions & 6 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ macro_rules! write_style {
ColorChoice::Auto => write!(
$stream,
"{}",
$message $(.if_supports_color($stream.owo(), |text| text.$style()))*
$message $(.if_supports_color($stream.owo().unwrap(), |text| text.$style()))*
),
}?;
}};
Expand Down Expand Up @@ -451,19 +451,19 @@ fn get_verbosity(

pub trait Stream {
type TTY: IsTerminal;
const OWO: owo_colors::Stream;
const OWO: Option<owo_colors::Stream>;

#[must_use]
fn is_atty() -> bool;

fn owo(&self) -> owo_colors::Stream {
fn owo(&self) -> Option<owo_colors::Stream> {
Self::OWO
}
}

impl Stream for io::Stdin {
type TTY = io::Stdin;
const OWO: owo_colors::Stream = owo_colors::Stream::Stdin;
const OWO: Option<owo_colors::Stream> = None;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to do const OWO: owo_colors::Stream = owo_colors::Stream::Stdout; here even though that is wrong, but it avoids the Option and the unwrap().

Or split the trait. I was a bit worried as it is pub. OTOH, probably nobody else is using the lib.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking the api is fine. We dont guarantee that its stable

//! <strong>⚠️ Warning:</strong> The cross library is for internal


fn is_atty() -> bool {
io::stdin().is_terminal()
Expand All @@ -472,7 +472,7 @@ impl Stream for io::Stdin {

impl Stream for io::Stdout {
type TTY = io::Stdout;
const OWO: owo_colors::Stream = owo_colors::Stream::Stdout;
const OWO: Option<owo_colors::Stream> = Some(owo_colors::Stream::Stdout);

fn is_atty() -> bool {
io::stdout().is_terminal()
Expand All @@ -481,7 +481,7 @@ impl Stream for io::Stdout {

impl Stream for io::Stderr {
type TTY = io::Stderr;
const OWO: owo_colors::Stream = owo_colors::Stream::Stderr;
const OWO: Option<owo_colors::Stream> = Some(owo_colors::Stream::Stderr);

fn is_atty() -> bool {
io::stderr().is_terminal()
Expand Down
Loading