Skip to content

indicatif

Developer UtilitiesCLI/UtilsRust

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 indicatif

Getting started

The smallest useful thing you can do with it, and what each part means.

Progress bars and spinners
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));
enable_steady_tick is needed for spinners during blocking work — otherwise the animation only advances when you happen to call tick().

Advanced usage

Where the library earns its place over a simpler alternative.

Parallel progress and logging together
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");
Calling println! directly while a bar is drawing garbles the output. ProgressBar::println (or the indicatif-log bridge) suspends the bar for the duration of the write.

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.