progress_bar.rs
This file
Path
src/output/progress_bar.rs
31 lines · 1.1 KiB · Rust
Last changed by
fix: add a space in the progress bar templateoverclockworked64before adoption798ea2d
History of this fileTake it
The walk stopped after 200 commits: lines older than b38bfc8 point at it.
Update dependenciesDavid Peterbefore adoptionb38bfc8
lines 1–17why, one step back1use indicatif::{ProgressBar, ProgressStyle};2use std::time::Duration;34use crate::options::OutputStyleOption;56#[cfg(not(windows))]7const TICK_SETTINGS: (&str, u64) = ("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ ", 80);89#[cfg(windows)]10const TICK_SETTINGS: (&str, u64) = (r"+-x| ", 200);1112/// Return a pre-configured progress bar13pub fn get_progress_bar(length: u64, msg: &str, option: OutputStyleOption) -> ProgressBar {14 let progressbar_style = match option {15 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),16 _ => ProgressStyle::default_spinner()17 .tick_chars(TICK_SETTINGS.0)fix: add a space in the progress bar templateoverclockworked64before adoption798ea2d
line 18why, one step back18 .template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise} ")Update dependenciesDavid Peterbefore adoptionb38bfc8
lines 19–31why, one step back19 .expect("no template error"),20 };2122 let progress_bar = match option {23 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressBar::hidden(),24 _ => ProgressBar::new(length),25 };26 progress_bar.set_style(progressbar_style);27 progress_bar.enable_steady_tick(Duration::from_millis(TICK_SETTINGS.1));28 progress_bar.set_message(msg.to_owned());2930 progress_bar31}