console-rs / indicatif

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

Setting length to `None` to change a bar to a spinner, and back #506

Closed azriel91 closed 1 year ago

azriel91 commented 1 year ago

Heya, would allowing a progress bar's length to be set to None be a sensible thing to support?

Currently ProgressBar::set_length takes len: u64, and internally sets its state's length to Some(len). In my usage of indicatif, I want to:

That said, as it stands, I think I could achieve the same effect by removing and adding bars, instead of reusing an existing bar.

djc commented 1 year ago

Yeah, I'm not sure it makes sense to support this use case. You could instead set the length to 0, or remove/add bars as needed.

azriel91 commented 1 year ago

cool thanks!