aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-01-29 22:37:03 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-01-29 22:37:03 +0100
commit86095df8b219510bf5cfb9f5d672695bd8b889c6 (patch)
tree4da550861f40ae39f68a5bd78d30f531e4187ed9
parente07c113c6bdd397002ecaaf21766532d4d3ded13 (diff)
downloadmihi-86095df8b219510bf5cfb9f5d672695bd8b889c6.tar.gz
mihi-86095df8b219510bf5cfb9f5d672695bd8b889c6.zip
run: show the exercise's lessons at the end
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--crates/cli/src/run.rs7
-rw-r--r--lib/mihi/src/exercise.rs2
2 files changed, 7 insertions, 2 deletions
diff --git a/crates/cli/src/run.rs b/crates/cli/src/run.rs
index 5f06870..0262515 100644
--- a/crates/cli/src/run.rs
+++ b/crates/cli/src/run.rs
@@ -535,7 +535,12 @@ fn run_exercises(exercises: Vec<Exercise>) -> bool {
// (i.e. refresh the 'updated_at' date). This way, next time we select
// exercises to show the user, we can prevent this one showing up first.
if accepted_diff(&solution, &exercise.solution) {
- let _ = touch_exercise(exercise);
+ let _ = touch_exercise(&exercise);
+ }
+
+ let lessons = exercise.lessons.trim();
+ if !lessons.is_empty() {
+ println!("The lessons for this exercise were:\n{}", lessons);
}
}
diff --git a/lib/mihi/src/exercise.rs b/lib/mihi/src/exercise.rs
index 5f45079..7249919 100644
--- a/lib/mihi/src/exercise.rs
+++ b/lib/mihi/src/exercise.rs
@@ -152,7 +152,7 @@ pub fn update_exercise(exercise: Exercise) -> Result<(), String> {
}
/// Updates the 'updated_at' column for an exercise.
-pub fn touch_exercise(exercise: Exercise) -> Result<(), String> {
+pub fn touch_exercise(exercise: &Exercise) -> Result<(), String> {
if exercise.id == 0 {
return Err("invalid exercise to update; seems it has not been created before".to_string());
}