From 68388e5d4f73ca7717eff0e668aa89f5c3a2124e Mon Sep 17 00:00:00 2001
From: azzamsa <me@azzamsa.com>
Date: Mon, 3 Oct 2022 19:56:46 +0700
Subject: [PATCH] feat(verify): add progress percentage in watch mode

---
 src/main.rs   | 2 +-
 src/verify.rs | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index cd79d9ff..8a17a35f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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
diff --git a/src/verify.rs b/src/verify.rs
index 6f877831..595990d2 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -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);
@@ -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(())