From e7ba88f90594962795bd028a8537efd6b1eedf6e Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 20 Aug 2024 16:04:29 +0200 Subject: [PATCH] Highlight the solution file --- src/run.rs | 15 +++++++++------ src/watch/state.rs | 23 +++++++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/run.rs b/src/run.rs index 964e13b..0bc965c 100644 --- a/src/run.rs +++ b/src/run.rs @@ -33,18 +33,21 @@ pub fn run(app_state: &mut AppState) -> Result<()> { )?; if let Some(solution_path) = app_state.current_solution_path()? { - println!( - "\nA solution file can be found at {}\n", - style(TerminalFileLink(&solution_path)).underlined().green(), - ); + writeln!( + stdout, + "\n{} for comparison: {}\n", + "Solution".bold(), + style(TerminalFileLink(&solution_path)).underlined().cyan(), + )?; } match app_state.done_current_exercise(&mut stdout)? { ExercisesProgress::AllDone => (), - ExercisesProgress::CurrentPending | ExercisesProgress::NewPending => println!( + ExercisesProgress::CurrentPending | ExercisesProgress::NewPending => writeln!( + stdout, "Next exercise: {}", app_state.current_exercise().terminal_link(), - ), + )?, } Ok(()) diff --git a/src/watch/state.rs b/src/watch/state.rs index abfff7a..fe972fa 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -137,21 +137,20 @@ impl<'a> WatchState<'a> { } if self.done_status != DoneStatus::Pending { - writeln!( - self.writer, - "{}\n", - "Exercise done ✓ -When you are done experimenting, enter `n` to move on to the next exercise 🦀" - .bold() - .green(), - )?; - } + writeln!(self.writer, "{}", "Exercise done ✓".bold().green())?; + + if let DoneStatus::DoneWithSolution(solution_path) = &self.done_status { + writeln!( + self.writer, + "{} for comparison: {}", + "Solution".bold(), + style(TerminalFileLink(solution_path)).underlined().cyan(), + )?; + } - if let DoneStatus::DoneWithSolution(solution_path) = &self.done_status { writeln!( self.writer, - "A solution file can be found at {}\n", - style(TerminalFileLink(solution_path)).underlined().green(), + "When done experimenting, enter `n` to move on to the next exercise 🦀\n", )?; }