From 66769caa57c3d6bbf778ba57edf4b1a6d1a5822a Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 25 Mar 2024 02:43:57 +0100 Subject: [PATCH] Even fancier --- src/util/progress.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/util/progress.rs b/src/util/progress.rs index 06562a4..f012714 100644 --- a/src/util/progress.rs +++ b/src/util/progress.rs @@ -2,17 +2,23 @@ use std::time::Duration; use indicatif::{ProgressBar, ProgressStyle}; -const PROGRESS_BAR_TEMPLATE: &str = "{msg} [{bar:32.cyan/blue}] {pos} / {len}"; -const PROGRESS_BAR_CHARACTERS: &str = "▪▸-"; +const PROGRESS_BAR_TEMPLATE: &str = + "{spinner:.bold.cyan} {msg:>11.bold.cyan} [{bar:32}] {pos} / {len}"; +const PROGRESS_BAR_CHARACTERS: &str = "=> "; +const PROGRESS_BAR_TICKERS: &str = "⠙⠹⠸⠼⠴⠦⠧⠇⠏ "; + +fn new_progress_style() -> ProgressStyle { + ProgressStyle::with_template(PROGRESS_BAR_TEMPLATE) + .unwrap() + .progress_chars(PROGRESS_BAR_CHARACTERS) + .tick_chars(PROGRESS_BAR_TICKERS) +} pub fn new_progress_bar(message: impl Into, length: usize) -> ProgressBar { - let pb = ProgressBar::new(length as u64) - .with_message(message.into()) - .with_style( - ProgressStyle::with_template(PROGRESS_BAR_TEMPLATE) - .unwrap() - .progress_chars(PROGRESS_BAR_CHARACTERS), - ); - pb.enable_steady_tick(Duration::from_millis(10)); + let pb = ProgressBar::new_spinner() + .with_style(new_progress_style()) + .with_message(message.into()); + pb.enable_steady_tick(Duration::from_millis(60)); + pb.set_length(length as u64); pb }