diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -269,11 +269,19 @@ pub fn run(matches: ArgMatches) -> Result<(), Box<dyn Error>> { } } - // check no_color here, allow override of via arg below + // check no_color here + // override via ARG_CLR below if is_no_color() { colorize = false; } + // prevent term color codes being sent to stdout + // test: cat Cargo.toml | target/debug/hx | more + // override via ARG_CLR below + if !atty::is(Stream::Stdout) { + colorize = false; + } + if let Some(color) = matches.value_of(ARG_CLR) { let color_v = color.parse::<u8>().unwrap(); if color_v == 1 { @@ -283,12 +291,6 @@ pub fn run(matches: ArgMatches) -> Result<(), Box<dyn Error>> { } } - // prevent term color codes being sent to stdout - // test: cat Caqrgo.toml | target/debug/hx | more - if !atty::is(Stream::Stdout) { - colorize = false; - } - // array output mode is mutually exclusive if let Some(array) = matches.value_of(ARG_ARR) { output_array(array, buf, truncate_len, column_width)?; |