Skip to content

Commit

Permalink
fix progress bar names
Browse files Browse the repository at this point in the history
  • Loading branch information
maxomatic458 committed May 18, 2024
1 parent 7f468ea commit 304d15d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ pub fn progress_bars(files: &[FileOrDir]) -> (Vec<ProgressBar>, Option<ProgressB
let total_name = "Total";

let style = ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({eta})").unwrap()
.template("{spinner:.green} {prefix} [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({eta})").unwrap()
.progress_chars("##-");

let total_style = ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.yellow/yellow}] {bytes}/{total_bytes} ({eta})").unwrap()
.template("{spinner:.green} {prefix} [{bar:40.yellow/yellow}] {bytes}/{total_bytes} ({eta})").unwrap()
.progress_chars("##-");

let longest_name = files.iter().map(|f| f.name().len()).max().unwrap_or(0);
Expand All @@ -61,6 +61,7 @@ pub fn progress_bars(files: &[FileOrDir]) -> (Vec<ProgressBar>, Option<ProgressB
}

let total_bar = if bars.len() > 1 {
let total_name = format!("{:width$}", total_name, width = longest_name);
let bar = mp.add(ProgressBar::new(total_size));
bar.set_style(total_style);
bar.set_prefix(total_name);
Expand Down

0 comments on commit 304d15d

Please sign in to comment.