use indicatif::{ProgressBar, ProgressStyle};
pub(in crate::api) fn make_progress_callback() -> impl Fn(u32, u32) + Send + Sync + 'static {
let pb = ProgressBar::new(0);
pb.set_style(
ProgressStyle::with_template(
"{spinner:.green} [{bar:40.cyan/blue}] {pos}/{len} ({percent}%)",
)
.unwrap_or_else(|_| ProgressStyle::default_bar()),
);
move |fetched, total| {
if fetched == 0 {
pb.set_length(u64::from(total));
}
pb.set_position(u64::from(fetched));
if fetched >= total {
pb.finish_with_message("done");
}
}
}