console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.22k stars 238 forks source link

Add builder-like `with_finish` method to `ProgressBarIter`. #548

Closed matthewhchan closed 1 year ago

matthewhchan commented 1 year ago

This lets you more concisely set the finish behavior of the progress bar when using ProgressBarIter.

For example, to show a progress bar and keep it displayed when it finishes, you can do

v.iter().progress().with_finish(ProgressFinish::AndLeave)

instead of

v.iter()
        .progress_with(ProgressBar::new(v.len() as u64).with_finish(ProgressFinish::AndLeave));

Closes #545

djc commented 1 year ago

Thanks!