use indicatif::{ProgressBar, ProgressFinish, ProgressStyle};
use std::time::Duration;
const FINISH: ProgressFinish = ProgressFinish::AndClear;

pub fn get_style(message: &str, len: usize) -> ProgressBar {
    let style = ProgressBar::new(len as u64);
    style.set_message(message.to_string());
    style.set_style(
        ProgressStyle::with_template("[{elapsed_precise}] {msg} [{wide_bar}] {pos}/{len}")
            .unwrap()
            .progress_chars("#> "),
    );
    style.with_finish(FINISH)
}

pub fn get_spinner(message: &str) -> ProgressBar {
    let style = ProgressBar::new_spinner();
    style.set_message(message.to_string());
    style.set_style(
        ProgressStyle::with_template("[{elapsed_precise}] {msg} {spinner} {pos}").unwrap(),
    );
    style.enable_steady_tick(Duration::from_millis(50));
    style.with_finish(FINISH)
}
