summaryrefslogtreecommitdiff
path: root/src/progress_bar.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-09 22:15:41 +0200
committermo8it <mo8it@proton.me>2024-04-09 22:15:41 +0200
commita8ddc07a9aea5b2e3840a7b6e0eb20f2189bdd60 (patch)
treea8e5ca2c572e15cb4932569cff644c7d9a68e550 /src/progress_bar.rs
parentaf85f2036cd545013225da04e67257fe4f6a4179 (diff)
Add "exercises" to the end of the progress bar
Diffstat (limited to 'src/progress_bar.rs')
-rw-r--r--src/progress_bar.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/progress_bar.rs b/src/progress_bar.rs
index b4abbfc..ee55ba7 100644
--- a/src/progress_bar.rs
+++ b/src/progress_bar.rs
@@ -7,13 +7,13 @@ pub fn progress_bar(progress: u16, total: u16, line_width: u16) -> Result<String
}
// "Progress: [".len() == 11
- // "] xxx/xxx".len() == 9
- // 11 + 9 = 20
- let wrapper_width = 20;
+ // "] xxx/xx exercises_".len() == 19 (leaving the last char empty for `total` > 99)
+ // 11 + 19 = 30
+ let wrapper_width = 30;
// If the line width is too low for a progress bar, just show the ratio.
if line_width < wrapper_width + 4 {
- return Ok(format!("Progress: {progress}/{total}"));
+ return Ok(format!("Progress: {progress}/{total} exercises"));
}
let mut line = String::with_capacity(usize::from(line_width));
@@ -34,7 +34,7 @@ pub fn progress_bar(progress: u16, total: u16, line_width: u16) -> Result<String
line.push(' ');
}
- line.write_fmt(format_args!("] {progress:>3}/{total:<3}"))
+ line.write_fmt(format_args!("] {progress:>3}/{total} exercises"))
.unwrap();
Ok(line)