use loaders::{Color, ColorSpec, ProgressBar, ProgressChars, ProgressStyle};
use std::thread;
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let style = ProgressStyle::with_template(
"{prefix} [{bar:32}] {percent:.1}% | left {human_remaining} | {rate} | {status} | {msg}",
)?
.progress_chars_set(ProgressChars::blocks())
.color(ColorSpec::new().set_fg(Color::BrightCyan).set_bold(true));
let pb = ProgressBar::with_style(120, style);
pb.set_prefix("custom");
pb.set_message("rendering frames");
pb.set_draw_delta(5);
pb.set_draw_rate(20);
for step in 0..120 {
if step == 60 {
pb.set_message("second pass");
}
pb.inc(1);
thread::sleep(Duration::from_millis(4));
}
pb.finish_with_symbol("ok", "advanced custom bar complete");
println!(
"final: {:.1}% complete, {} remaining",
pb.percent(),
pb.remaining().unwrap_or(0)
);
Ok(())
}