util/cli: Add spinner utility.

This commit is contained in:
parazyd
2022-08-04 13:57:37 +02:00
parent 757eefc181
commit f9f11ad45a

View File

@@ -4,8 +4,10 @@ use std::{
marker::PhantomData,
path::{Path, PathBuf},
str,
time::Duration,
};
use indicatif::{ProgressBar, ProgressStyle};
use serde::{de::DeserializeOwned, Serialize};
use simplelog::ConfigBuilder;
@@ -196,3 +198,13 @@ macro_rules! async_daemonize {
}
};
}
pub fn progress_bar(message: &str) -> ProgressBar {
let progress_bar = ProgressBar::new(42);
progress_bar.set_style(
ProgressStyle::default_spinner().template("{spinner:.green} {wide_msg}").unwrap(),
);
progress_bar.enable_steady_tick(Duration::from_millis(100));
progress_bar.set_message(message.to_string());
progress_bar
}