console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.45k stars 243 forks source link

feat: allow constructing and setting the progress bar len to `None` #664

Closed cdellacqua closed 1 week ago

cdellacqua commented 2 weeks ago

For situations where the length of a progress bar can only be discovered after some processing, it might be more appropriate to show an empty bar rather than a full one of length 0 (0/0 is represented with a ratio of 1.0).

This PR introduces a new constructor, ProgressBar::empty(), and a new method, ProgressBar::unset_length(). These two allow library users to have a length of None, which is represented as a ratio of 0.0, achieving the empty state.