summaryrefslogtreecommitdiffstats
path: root/src/util/progress.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-10-28 18:04:08 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-10-28 18:04:08 +0100
commit97662a1abb69f7ddc060dbf70409478d21c21e0b (patch)
treea2938e28ac8b8b8496e9d0a9c9d3f294674929b0 /src/util/progress.rs
parente438308cd34c1d1a2f9404c19f5aaa93c855c2ff (diff)
Move progress bar setup to utility module
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/util/progress.rs')
-rw-r--r--src/util/progress.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util/progress.rs b/src/util/progress.rs
new file mode 100644
index 0000000..5ddf383
--- /dev/null
+++ b/src/util/progress.rs
@@ -0,0 +1,35 @@
+use indicatif::*;
+
+pub struct ProgressBars {
+ pub root: MultiProgress,
+ pub release_loading: ProgressBar,
+ pub staging_loading: ProgressBar,
+ pub repo_loading: ProgressBar,
+ pub tree_building: ProgressBar,
+}
+
+impl ProgressBars {
+ pub fn setup(max_packages: u64) -> Self {
+ fn bar(msg: &str, max_packages: u64) -> ProgressBar {
+ let b = ProgressBar::new(max_packages);
+ b.set_style({
+ ProgressStyle::default_bar()
+ .template("[{elapsed_precise}] {pos:>3}/{len:>3} ({percent:>3}%): {bar} | {msg}")
+ });
+
+ b.set_message(msg);
+ b
+ }
+
+ let root = MultiProgress::new();
+ ProgressBars {
+ repo_loading: root.add(bar("Repository loading", max_packages)),
+ staging_loading: root.add(bar("Loading staging", max_packages)),
+ release_loading: root.add(bar("Loading releases", max_packages)),
+ tree_building: root.add(bar("Building package tree", max_packages)),
+ root,
+ }
+ }
+}
+
+