What it is
indicatif renders progress bars, spinners and multi-progress displays for Rust command-line programs.
Create a ProgressBar with a known length or an indeterminate spinner, update as work proceeds, and finish with a message. Integrates with Rayon for parallel work.
Installation
cargo add indicatifGetting started
The smallest useful thing you can do with it, and what each part means.
rust
use indicatif::{ProgressBar, ProgressStyle};
let bar = ProgressBar::new(files.len() as u64);
bar.set_style(
ProgressStyle::with_template(
"{spinner} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})"
)?
.progress_chars("=>-"),
);
for file in &files {
process(file)?;
bar.inc(1);
}
bar.finish_with_message("done");
// Unknown duration: a spinner instead.
let spinner = ProgressBar::new_spinner();
spinner.enable_steady_tick(Duration::from_millis(100));Advanced usage
Where the library earns its place over a simpler alternative.
rust
use indicatif::MultiProgress;
use rayon::prelude::*;
let multi = MultiProgress::new();
let overall = multi.add(ProgressBar::new(jobs.len() as u64));
jobs.par_iter().for_each(|job| {
let bar = multi.add(ProgressBar::new(job.steps));
run(job, &bar);
bar.finish_and_clear();
overall.inc(1);
});
// Printing normally corrupts the bar; go through the bar instead.
overall.println("finished a batch");Errors and fixes
The failures you are most likely to hit, and what actually resolves them.
- Output is interleaved and garbled
- Something wrote to stdout directly. Route all output through the ProgressBar or MultiProgress.
- The spinner does not move
- No ticks are occurring. Call enable_steady_tick, which animates on its own thread.
Best practices
- Use bar.println rather than println! while a bar is active, or the display corrupts.
- Call enable_steady_tick for spinners around blocking operations.
- Hide progress when stdout is not a terminal — piped output should stay clean.
- Do not update the bar every iteration in a very tight loop; the redraws can dominate the work.
Background
Why it exists, and what it was reacting to.
From Armin Ronacher, indicatif is the Rust counterpart to Python's tqdm — the small quality-of-life library that makes a long-running CLI feel responsive rather than hung.
