progress_bar.rs
This file
Path
src/output/progress_bar.rs
29 lines · 1.0 KiB · Rust
Last changed by
New output moduleDavid Peterbefore adoption865290a
History of this fileTake it
New output moduleDavid Peterbefore adoption865290a
lines 1–29why, one step back1use indicatif::{ProgressBar, ProgressStyle};23use crate::options::OutputStyleOption;45#[cfg(not(windows))]6const TICK_SETTINGS: (&str, u64) = ("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ ", 80);78#[cfg(windows)]9const TICK_SETTINGS: (&str, u64) = (r"+-x| ", 200);1011/// Return a pre-configured progress bar12pub fn get_progress_bar(length: u64, msg: &str, option: OutputStyleOption) -> ProgressBar {13 let progressbar_style = match option {14 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),15 _ => ProgressStyle::default_spinner()16 .tick_chars(TICK_SETTINGS.0)17 .template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),18 };1920 let progress_bar = match option {21 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressBar::hidden(),22 _ => ProgressBar::new(length),23 };24 progress_bar.set_style(progressbar_style);25 progress_bar.enable_steady_tick(TICK_SETTINGS.1);26 progress_bar.set_message(msg.to_owned());2728 progress_bar29}