Skip to content

Commit

Permalink
feat(verify): add progress percentage in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
azzamsa committed Oct 13, 2022
1 parent 56a4f16 commit 68388e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn main() {
});
let percentage_progress = exercises_done as f32 / exercises.len() as f32 * 100.0;
println!(
"Progress: You completed {} / {} exercises ({:.2} %).",
"Progress: You completed {} / {} exercises ({:.1} %).",
exercises_done,
exercises.len(),
percentage_progress
Expand Down
4 changes: 3 additions & 1 deletion src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn verify<'a>(
let (num_done, total) = progress;
let bar = ProgressBar::new(total as u64);
bar.set_style(ProgressStyle::default_bar()
.template("Progress: [{bar:60.green/red}] {pos}/{len}")
.template("Progress: [{bar:60.green/red}] {pos}/{len} {msg}")
.progress_chars("#>-")
);
bar.set_position(num_done as u64);
Expand All @@ -29,6 +29,8 @@ pub fn verify<'a>(
if !compile_result.unwrap_or(false) {
return Err(exercise);
}
let percentage = num_done as f32 / total as f32 * 100.0;
bar.set_message(format!("({:.1} %)", percentage));
bar.inc(1);
}
Ok(())
Expand Down

0 comments on commit 68388e5

Please sign in to comment.