use indicatif::{ProgressBar, ProgressStyle};
use std::time::Duration;
const TICKS: &[&str] = &["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷", "⣾"];
pub fn bar(label: &str, total: usize, show: bool) -> ProgressBar {
if !show || total == 0 {
return ProgressBar::hidden();
}
let pb = ProgressBar::new(total as u64);
pb.set_style(
ProgressStyle::with_template(
" {spinner:.cyan} {msg} [{bar:24.cyan/dim}] {pos}/{len} {elapsed:.dim}",
)
.expect("valid progress template")
.progress_chars("█▉▊▋▌▍▎▏ ")
.tick_strings(TICKS),
);
pb.set_message(label.to_string());
pb.enable_steady_tick(Duration::from_millis(100));
pb
}