diff options
| author | mo8it <mo8it@proton.me> | 2024-04-11 02:51:02 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-11 02:51:02 +0200 |
| commit | fa1f239a702eb2c0b7e0115e986481156961bbc8 (patch) | |
| tree | 08ac7c8638546f80ac650474dfe4126103a15e54 /src/run.rs | |
| parent | 4bb6bda9f6416e30233342e73fc9a8486faa3f98 (diff) | |
Remove "I AM NOT DONE" and the verify mode and add AppState
Diffstat (limited to 'src/run.rs')
| -rw-r--r-- | src/run.rs | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -2,13 +2,10 @@ use anyhow::{bail, Result}; use crossterm::style::Stylize; use std::io::{stdout, Write}; -use crate::exercise::Exercise; +use crate::app_state::{AppState, ExercisesProgress}; -// Invoke the rust compiler on the path of the given exercise, -// and run the ensuing binary. -// The verbose argument helps determine whether or not to show -// the output from the test harnesses (if the mode of the exercise is test) -pub fn run(exercise: &Exercise) -> Result<()> { +pub fn run(app_state: &mut AppState) -> Result<()> { + let exercise = app_state.current_exercise(); let output = exercise.run()?; { @@ -22,7 +19,19 @@ pub fn run(exercise: &Exercise) -> Result<()> { bail!("Ran {exercise} with errors"); } - println!("{}", "✓ Successfully ran {exercise}".green()); + println!( + "{}{}", + "✓ Successfully ran ".green(), + exercise.path.to_string_lossy().green(), + ); + + match app_state.done_current_exercise()? { + ExercisesProgress::AllDone => println!( + "🎉 Congratulations! You have done all the exercises! +🔚 There are no more exercises to do next!" + ), + ExercisesProgress::Pending => println!("Next exercise: {}", app_state.current_exercise()), + } Ok(()) } |
