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 3013c9d point at it.
Bump clap from 3.2.8 to 3.2.16dependabot[bot]before adoption3013c9d
line 1why, one step back1use indicatif::{ProgressBar, ProgressStyle};Updates for indicatif 0.17David Peterbefore adoption71c139c
line 2why, one step back2use std::time::Duration;Bump clap from 3.2.8 to 3.2.16dependabot[bot]before adoption3013c9d
lines 3–17why, one step back34use 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} ")Updates for indicatif 0.17David Peterbefore adoption71c139c
line 19why, one step back19 .expect("no template error"),Bump clap from 3.2.8 to 3.2.16dependabot[bot]before adoption3013c9d
lines 20–26why, one step back20 };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);Updates for indicatif 0.17David Peterbefore adoption71c139c
line 27why, one step back27 progress_bar.enable_steady_tick(Duration::from_millis(TICK_SETTINGS.1));Bump clap from 3.2.8 to 3.2.16dependabot[bot]before adoption3013c9d
lines 28–31why, one step back28 progress_bar.set_message(msg.to_owned());2930 progress_bar31}