diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-09 17:18:35 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-09 17:23:55 +0100 |
commit | e91869e46fc39e1a6e91dce5c603911fcaad10f5 (patch) | |
tree | aceb1d697384347d6991b4d70f50a18a21f6ad15 /src/util/progress.rs | |
parent | 2205057859f8321496a8a800c242c6cd82fef168 (diff) |
Fix weird rendering bug of progress bars
Apparently, this fixes the rendering bug we had with indicatif.
The issue was, that we called `indicatif::ProgressBar::set_message()`
before the bar was added to the `indicatif::MultiProgress` object.
This caused the bar to be rendered, and as soon we added it to the
MultiProgress object and re-called set_message(), it was rendered again.
This is of course a bug / inconveniance in indicatif.
Either way, the issue was solved by not calling `set_message()` in our
`ProgressBars` helper object, but only return a preconfigured bar
object.
Because not calling the set_message() function yields the whole bunch of
helper functions as unnecessary, these were removed and the interface
was boiled down to `pub fn ProgressBars::bar(&self) ->
indicatif::ProgressBar` which in turn results in a few modifications all
over the place.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/util/progress.rs')
-rw-r--r-- | src/util/progress.rs | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/src/util/progress.rs b/src/util/progress.rs index 5874624..8358dcc 100644 --- a/src/util/progress.rs +++ b/src/util/progress.rs @@ -1,8 +1,4 @@ -use std::path::PathBuf; - use indicatif::*; -use uuid::Uuid; -use url::Url; #[derive(Clone, Debug)] pub struct ProgressBars { @@ -20,59 +16,22 @@ impl ProgressBars { } } - pub fn tree_building(&self) -> ProgressBar { - self.bar("Building package tree", &self.bar_template) - } - - pub fn repo_loading(&self) -> ProgressBar { - self.bar("Repository loading", &self.bar_template) - } - - pub fn staging_loading(&self) -> ProgressBar { - self.bar("Loading staging", &self.bar_template) - } - - pub fn release_loading(&self) -> ProgressBar { - self.bar("Loading releases", &self.bar_template) - } - - pub fn what_depends(&self) -> ProgressBar { - self.bar("Crawling dependencies", &self.bar_template) - } - - pub fn job_bar(&self, id: &Uuid) -> ProgressBar { - let b = self.bar(&format!("Job: {}", id), &self.bar_template); - b.set_length(100); - b - } - - pub fn download_bar(&self, url: &Url) -> ProgressBar { - self.bar(&format!("Download: {}", url.as_str()), &self.bar_template) - } - - pub fn verification_bar(&self, path: PathBuf) -> ProgressBar { - self.spinner(&self.spinner_template, format!("Verification: {}", path.display())) - } - - fn bar(&self, msg: &str, template: &str) -> ProgressBar { + pub fn bar(&self) -> ProgressBar { if self.hide { ProgressBar::hidden() } else { let b = ProgressBar::new(1); - b.set_style(ProgressStyle::default_bar().template(template)); - b.set_message(msg); + b.set_style(ProgressStyle::default_bar().template(&self.bar_template)); b } } - fn spinner(&self, template: &str, msg: String) -> ProgressBar { + pub fn spinner(&self) -> ProgressBar { if self.hide { ProgressBar::hidden() } else { let bar = ProgressBar::new_spinner(); - bar.set_style(ProgressStyle::default_spinner().template(template)); - bar.enable_steady_tick(100); - bar.set_message(&msg); + bar.set_style(ProgressStyle::default_spinner().template(&self.spinner_template)); bar } } |