From 342e43a981f092d867d52c29809c1d812b553cd1 Mon Sep 17 00:00:00 2001 From: Tom Dong Date: Sat, 7 Sep 2019 16:03:15 -0700 Subject: [PATCH] Support increasing the length of the progress bar with a delta. (#110) This is useful when new work arrives when tracking the progress of existing work. --- src/progress.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/progress.rs b/src/progress.rs index 243e4b65..7b6361e2 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -554,6 +554,13 @@ impl ProgressBar { }) } + /// Increase the length of the progress bar. + pub fn inc_length(&self, delta: u64) { + self.update_and_draw(|state| { + state.len = state.len.saturating_add(delta); + }) + } + /// Sets the current prefix of the progress bar. pub fn set_prefix(&self, prefix: &str) { let prefix = prefix.to_string();