From 5bd76fd11b9e992c2b52ed2047cb473513541807 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Tue, 6 Dec 2022 11:24:53 -0500 Subject: [PATCH 1/7] Replace `is-terminal` with `supports-color` and make `auto` default for color --- Cargo.toml | 2 +- src/bin/hexyl.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f0c27696..76e00e35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,8 @@ edition = "2021" anstyle = "0.2" anyhow = "1.0" const_format = "0.2" -is-terminal = "0.4" libc = "0.2" +supports-color = "1" thiserror = "1.0" terminal_size = "0.2" diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 3ecf1b0c..32a231b4 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -9,8 +9,6 @@ use std::num::{NonZeroI64, NonZeroU64, NonZeroU8}; use clap::builder::ArgPredicate; use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command}; -use is_terminal::IsTerminal; - use anyhow::{anyhow, Context, Result}; use const_format::formatcp; @@ -106,7 +104,7 @@ fn run() -> Result<()> { .value_name("WHEN") .value_parser(["always", "auto", "never"]) .default_value_if("plain", ArgPredicate::IsPresent, Some("never")) - .default_value("always") + .default_value("auto") .help( "When to use colors. The auto-mode only displays colors if the output \ goes to an interactive terminal", @@ -293,8 +291,10 @@ fn run() -> Result<()> { let show_color = match matches.get_one::("color").map(String::as_ref) { Some("never") => false, - Some("auto") => std::io::stdout().is_terminal(), - _ => true, + Some("always") => true, + _ => supports_color::on_cached(supports_color::Stream::Stdout) + .map(|level| level.has_basic) + .unwrap_or(false), }; let border_style = match matches.get_one::("border").map(String::as_ref) { From 4ce6e9d799f3a26c1f948a3ed81655855be25302 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Tue, 6 Dec 2022 11:26:19 -0500 Subject: [PATCH 2/7] Remove now unnecessary `byte_char_panel_g` --- src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 46f8503f..72b983d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -257,7 +257,6 @@ pub struct Printer<'a, Writer: Write> { byte_char_panel: Vec, // same as previous but in Fixed(242) gray color, for position panel byte_hex_panel_g: Vec, - byte_char_panel_g: Vec, squeezer: Squeezer, display_offset: u64, /// The number of panels to draw. @@ -311,9 +310,6 @@ impl<'a, Writer: Write> Printer<'a, Writer> { .map(|i| format!("{}", Byte(i).as_char())) .collect(), byte_hex_panel_g: (0u8..=u8::MAX).map(|i| format!("{i:02x}")).collect(), - byte_char_panel_g: (0u8..=u8::MAX) - .map(|i| format!("{}", Byte(i).as_char())) - .collect(), squeezer: if use_squeeze { Squeezer::Ignore } else { @@ -409,7 +405,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { match self.squeezer { Squeezer::Print => { self.writer - .write_all(self.byte_char_panel_g[b'*' as usize].as_bytes())?; + .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { self.writer .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; @@ -504,7 +500,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { .write_all(self.colors[ByteColor::Offset as usize].as_bytes())?; } self.writer - .write_all(self.byte_char_panel_g[b'*' as usize].as_bytes())?; + .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { self.writer .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; From 4fc0c1f1b0cf4d9065eeb1cc3924334f48402b83 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Tue, 6 Dec 2022 11:27:16 -0500 Subject: [PATCH 3/7] Replace `anstyle` with `owo-colors` --- Cargo.lock | 58 ++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- src/lib.rs | 81 +++++++++++++++++------------------------------------- 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf6597b7..8fa671cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,12 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "anstyle" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bb0ec944fe041c41e32dcd60b49327fcb7ff761433838878cc97ddecf16db7" - [[package]] name = "anyhow" version = "1.0.66" @@ -37,6 +31,17 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -175,6 +180,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.2.6" @@ -188,15 +202,15 @@ dependencies = [ name = "hexyl" version = "0.11.0" dependencies = [ - "anstyle", "anyhow", "assert_cmd", "clap", "const_format", - "is-terminal", "libc", + "owo-colors", "predicates", "pretty_assertions", + "supports-color", "terminal_size", "thiserror", ] @@ -217,12 +231,18 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "io-lifetimes", "rustix", "windows-sys", ] +[[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + [[package]] name = "itertools" version = "0.10.5" @@ -286,6 +306,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + [[package]] name = "predicates" version = "2.1.4" @@ -371,9 +397,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustix" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" +checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" dependencies = [ "bitflags", "errno", @@ -395,6 +421,16 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + [[package]] name = "syn" version = "1.0.105" diff --git a/Cargo.toml b/Cargo.toml index 76e00e35..b4252d19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ version = "0.11.0" edition = "2021" [dependencies] -anstyle = "0.2" anyhow = "1.0" const_format = "0.2" libc = "0.2" +owo-colors = "3" supports-color = "1" thiserror = "1.0" terminal_size = "0.2" diff --git a/src/lib.rs b/src/lib.rs index 72b983d8..9ac85dc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ pub use input::*; use std::io::{self, BufReader, Read, Write}; -use anstyle::{AnsiColor, Reset}; +use owo_colors::{colors, Color}; pub enum Base { Binary, @@ -13,24 +13,13 @@ pub enum Base { Hexadecimal, } -#[derive(PartialEq, Eq)] -#[repr(usize)] -enum ByteColor { - Null = 0, - Offset = 1, - AsciiPrintable = 2, - AsciiWhitespace = 3, - AsciiOther = 4, - NonAscii = 5, - Reset = 6, -} - -const COLOR_NULL: AnsiColor = AnsiColor::BrightBlack; -const COLOR_OFFSET: AnsiColor = AnsiColor::BrightBlack; -const COLOR_ASCII_PRINTABLE: AnsiColor = AnsiColor::Cyan; -const COLOR_ASCII_WHITESPACE: AnsiColor = AnsiColor::Green; -const COLOR_ASCII_OTHER: AnsiColor = AnsiColor::Magenta; -const COLOR_NONASCII: AnsiColor = AnsiColor::Yellow; +const COLOR_NULL: &'static [u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_OFFSET: &'static [u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_ASCII_PRINTABLE: &'static [u8] = colors::Cyan::ANSI_FG.as_bytes(); +const COLOR_ASCII_WHITESPACE: &'static [u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_ASCII_OTHER: &'static [u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_NONASCII: &'static [u8] = colors::Yellow::ANSI_FG.as_bytes(); +const COLOR_RESET: &'static [u8] = colors::Default::ANSI_FG.as_bytes(); pub enum ByteCategory { Null, @@ -66,15 +55,15 @@ impl Byte { } } - fn color(self) -> ByteColor { + fn color(self) -> &'static [u8] { use crate::ByteCategory::*; match self.category() { - Null => ByteColor::Null, - AsciiPrintable => ByteColor::AsciiPrintable, - AsciiWhitespace => ByteColor::AsciiWhitespace, - AsciiOther => ByteColor::AsciiOther, - NonAscii => ByteColor::NonAscii, + Null => COLOR_NULL, + AsciiPrintable => COLOR_ASCII_PRINTABLE, + AsciiWhitespace => COLOR_ASCII_WHITESPACE, + AsciiOther => COLOR_ASCII_OTHER, + NonAscii => COLOR_NONASCII, } } @@ -250,8 +239,7 @@ pub struct Printer<'a, Writer: Write> { show_char_panel: bool, show_position_panel: bool, show_color: bool, - colors: Vec, - curr_color: Option, + curr_color: Option<&'static [u8]>, border_style: BorderStyle, byte_hex_panel: Vec, byte_char_panel: Vec, @@ -288,15 +276,6 @@ impl<'a, Writer: Write> Printer<'a, Writer> { show_position_panel, show_color, curr_color: None, - colors: vec![ - COLOR_NULL.render_fg().to_string(), - COLOR_OFFSET.render_fg().to_string(), - COLOR_ASCII_PRINTABLE.render_fg().to_string(), - COLOR_ASCII_WHITESPACE.render_fg().to_string(), - COLOR_ASCII_OTHER.render_fg().to_string(), - COLOR_NONASCII.render_fg().to_string(), - Reset.render().to_string(), - ], border_style, byte_hex_panel: (0u8..=u8::MAX) .map(|i| match base { @@ -398,8 +377,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { .as_bytes(), )?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Offset as usize].as_bytes())?; + self.writer.write_all(COLOR_OFFSET)?; } if self.show_position_panel { match self.squeezer { @@ -407,8 +385,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { self.writer .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } self.writer.write_all(b" ")?; } @@ -423,8 +400,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { .write_all(self.byte_hex_panel_g[byte as usize].as_bytes())?; } if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } } } @@ -444,8 +420,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { Squeezer::Ignore | Squeezer::Disabled => { if let Some(&b) = self.line_buf.get(i as usize) { if self.show_color && self.curr_color != Some(Byte(b).color()) { - self.writer - .write_all(self.colors[Byte(b).color() as usize].as_bytes())?; + self.writer.write_all(Byte(b).color())?; self.curr_color = Some(Byte(b).color()); } self.writer @@ -457,8 +432,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { } if i == 8 * self.panels - 1 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; self.curr_color = None; } self.writer.write_all( @@ -469,8 +443,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { )?; } else if i % 8 == 7 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; self.curr_color = None; } self.writer.write_all( @@ -496,14 +469,12 @@ impl<'a, Writer: Write> Printer<'a, Writer> { Squeezer::Print => { if !self.show_position_panel && i == 0 { if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Offset as usize].as_bytes())?; + self.writer.write_all(COLOR_OFFSET)?; } self.writer .write_all(self.byte_char_panel[b'*' as usize].as_bytes())?; if self.show_color { - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } } else { if i % (self.group_bytes as usize) == 0 { @@ -520,8 +491,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { self.writer.write_all(b" ")?; } if self.show_color && self.curr_color != Some(Byte(b).color()) { - self.writer - .write_all(self.colors[Byte(b).color() as usize].as_bytes())?; + self.writer.write_all(Byte(b).color())?; self.curr_color = Some(Byte(b).color()); } self.writer @@ -532,8 +502,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { if i % 8 == 7 { if self.show_color { self.curr_color = None; - self.writer - .write_all(self.colors[ByteColor::Reset as usize].as_bytes())?; + self.writer.write_all(COLOR_RESET)?; } self.writer.write_all(b" ")?; // byte is last in last panel From b2f0e75ed25fd979817d58f0aeefd7dc409c7609 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Tue, 6 Dec 2022 13:22:34 -0500 Subject: [PATCH 4/7] Satisfy `clippy` --- src/bin/hexyl.rs | 2 +- src/lib.rs | 36 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 32a231b4..798df623 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -449,7 +449,7 @@ fn main() { std::process::exit(0); } } - eprintln!("Error: {:?}", err); + eprintln!("Error: {err:?}"); std::process::exit(1); } } diff --git a/src/lib.rs b/src/lib.rs index 9ac85dc2..b4e8f6cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,13 +13,13 @@ pub enum Base { Hexadecimal, } -const COLOR_NULL: &'static [u8] = colors::BrightBlack::ANSI_FG.as_bytes(); -const COLOR_OFFSET: &'static [u8] = colors::BrightBlack::ANSI_FG.as_bytes(); -const COLOR_ASCII_PRINTABLE: &'static [u8] = colors::Cyan::ANSI_FG.as_bytes(); -const COLOR_ASCII_WHITESPACE: &'static [u8] = colors::Green::ANSI_FG.as_bytes(); -const COLOR_ASCII_OTHER: &'static [u8] = colors::Green::ANSI_FG.as_bytes(); -const COLOR_NONASCII: &'static [u8] = colors::Yellow::ANSI_FG.as_bytes(); -const COLOR_RESET: &'static [u8] = colors::Default::ANSI_FG.as_bytes(); +const COLOR_NULL: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_OFFSET: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); +const COLOR_ASCII_PRINTABLE: &[u8] = colors::Cyan::ANSI_FG.as_bytes(); +const COLOR_ASCII_WHITESPACE: &[u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_ASCII_OTHER: &[u8] = colors::Green::ANSI_FG.as_bytes(); +const COLOR_NONASCII: &[u8] = colors::Yellow::ANSI_FG.as_bytes(); +const COLOR_RESET: &[u8] = colors::Default::ANSI_FG.as_bytes(); pub enum ByteCategory { Null, @@ -329,27 +329,27 @@ impl<'a, Writer: Write> Printer<'a, Writer> { let h_repeat = h.to_string().repeat(self.panel_sz()); if self.show_position_panel { - write!(self.writer, "{l}{h8}{c}", l = l, c = c, h8 = h8).ok(); + write!(self.writer, "{l}{h8}{c}")?; } else { - write!(self.writer, "{}", l).ok(); + write!(self.writer, "{l}")?; } for _ in 0..self.panels - 1 { - write!(self.writer, "{h_repeat}{c}", h_repeat = h_repeat, c = c).ok(); + write!(self.writer, "{h_repeat}{c}")?; } if self.show_char_panel { - write!(self.writer, "{h_repeat}{c}", h_repeat = h_repeat, c = c).ok(); + write!(self.writer, "{h_repeat}{c}")?; } else { - write!(self.writer, "{h_repeat}", h_repeat = h_repeat).ok(); + write!(self.writer, "{h_repeat}")?; } if self.show_char_panel { for _ in 0..self.panels - 1 { - write!(self.writer, "{h8}{c}", h8 = h8, c = c).ok(); + write!(self.writer, "{h8}{c}")?; } - writeln!(self.writer, "{h8}{r}", h8 = h8, r = r).ok(); + writeln!(self.writer, "{h8}{r}")?; } else { - writeln!(self.writer, "{r}", r = r).ok(); + writeln!(self.writer, "{r}")?; } Ok(()) @@ -476,10 +476,8 @@ impl<'a, Writer: Write> Printer<'a, Writer> { if self.show_color { self.writer.write_all(COLOR_RESET)?; } - } else { - if i % (self.group_bytes as usize) == 0 { - self.writer.write_all(b" ")?; - } + } else if i % (self.group_bytes as usize) == 0 { + self.writer.write_all(b" ")?; } for _ in 0..self.base_digits { self.writer.write_all(b" ")?; From faa9866d1149e48f837076db1d6f9b7dd70df21c Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Wed, 7 Dec 2022 16:44:11 -0500 Subject: [PATCH 5/7] Change `group_bytes` to satisfy merge conflict --- src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b4e8f6cb..1d607936 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -251,7 +251,7 @@ pub struct Printer<'a, Writer: Write> { panels: u64, squeeze_byte: usize, /// The number of octets per group. - group_bytes: u8, + group_size: u8, /// The number of digits used to write the base. base_digits: u8, } @@ -265,7 +265,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { border_style: BorderStyle, use_squeeze: bool, panels: u64, - group_bytes: u8, + group_size: u8, base: Base, ) -> Printer<'a, Writer> { Printer { @@ -297,7 +297,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { display_offset: 0, panels, squeeze_byte: 0x00, - group_bytes, + group_size, base_digits: match base { Base::Binary => 8, Base::Octal => 3, @@ -314,8 +314,8 @@ impl<'a, Writer: Write> Printer<'a, Writer> { fn panel_sz(&self) -> usize { // add one to include the trailing space of a group - let group_sz = self.base_digits as usize * self.group_bytes as usize + 1; - let group_per_panel = 8 / self.group_bytes as usize; + let group_sz = self.base_digits as usize * self.group_size as usize + 1; + let group_per_panel = 8 / self.group_size as usize; // add one to include the leading space 1 + group_sz * group_per_panel } @@ -476,7 +476,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { if self.show_color { self.writer.write_all(COLOR_RESET)?; } - } else if i % (self.group_bytes as usize) == 0 { + } else if i % (self.group_size as usize) == 0 { self.writer.write_all(b" ")?; } for _ in 0..self.base_digits { @@ -485,7 +485,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { } Squeezer::Delete => self.writer.write_all(b" ")?, Squeezer::Ignore | Squeezer::Disabled => { - if i % (self.group_bytes as usize) == 0 { + if i % (self.group_size as usize) == 0 { self.writer.write_all(b" ")?; } if self.show_color && self.curr_color != Some(Byte(b).color()) { From cf8e7ec07911a936ae528110465921a9d14796fd Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Wed, 7 Dec 2022 16:48:20 -0500 Subject: [PATCH 6/7] Revert default color option to always --- src/bin/hexyl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 798df623..0e90b5ba 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -104,7 +104,7 @@ fn run() -> Result<()> { .value_name("WHEN") .value_parser(["always", "auto", "never"]) .default_value_if("plain", ArgPredicate::IsPresent, Some("never")) - .default_value("auto") + .default_value("always") .help( "When to use colors. The auto-mode only displays colors if the output \ goes to an interactive terminal", From dfd7bdef494a717e8f344267b5283a101437b6c3 Mon Sep 17 00:00:00 2001 From: sharif <61516383+sharifhsn@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:33:35 -0500 Subject: [PATCH 7/7] Update src/bin/hexyl.rs Co-authored-by: David Peter --- src/bin/hexyl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 50cea1b2..872df048 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -295,7 +295,7 @@ fn run() -> Result<()> { let show_color = match matches.get_one::("color").map(String::as_ref) { Some("never") => false, Some("always") => true, - _ => supports_color::on_cached(supports_color::Stream::Stdout) + _ => supports_color::on(supports_color::Stream::Stdout) .map(|level| level.has_basic) .unwrap_or(false), };