Skip to content

Commit

Permalink
Fix colors for indicatif if stdout is a pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd committed Jun 16, 2022
1 parent 3ac3f0e commit aa32c6d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
14 changes: 1 addition & 13 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 @@ -13,7 +13,7 @@ edition = "2018"
anyhow = "1.0.57"
atty = "0.2.11"
clap = { version = "3.2.5", features = ["derive"] }
clicolors-control = "1.0"
console = { version = "0.15.0", default-features = false }
env_logger = "0.9"
indicatif = "0.16"
log = "0.4"
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ impl Feedback for Silent {
}

struct Verbose(ProgressBar);

impl Feedback for Verbose {
#[inline]
fn new(total: usize) -> Verbose {
clicolors_control::set_colors_enabled(true);
console::set_colors_enabled(true);

let pb = ProgressBar::new(total as u64);
pb.set_draw_target(ProgressDrawTarget::stderr());
Expand Down Expand Up @@ -108,6 +109,7 @@ impl Stdout {
Stdout(io::stdout())
}
}

impl Sink for Stdout {
#[inline(always)]
fn write<'a>(&mut self, b: &'a[u8]) -> Result<Match<'a>> {
Expand Down

0 comments on commit aa32c6d

Please sign in to comment.