summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-18 17:17:39 +0200
committermo8it <mo8it@proton.me>2024-04-18 17:17:39 +0200
commita2be6754bf2833371fe99ddc2d01c0d518f8eb27 (patch)
tree0fdd334e94509802bf5277a7eb8cb82175f4f9ae /src/main.rs
parentdaa090981aeafb24ed907cf85de49904ce17fc37 (diff)
Make the exercise name option for the hint subcommand
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 0469737..4c5f114 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -63,10 +63,10 @@ enum Subcommands {
/// The name of the exercise
name: String,
},
- /// Return a hint for the given exercise
+ /// Show a hint. Shows the hint of the next pending exercise if the exercise name is not specified.
Hint {
/// The name of the exercise
- name: String,
+ name: Option<String>,
},
#[command(subcommand)]
Dev(DevCommands),
@@ -162,7 +162,9 @@ fn main() -> Result<()> {
println!("The exercise {exercise_path} has been reset");
}
Some(Subcommands::Hint { name }) => {
- app_state.set_current_exercise_by_name(&name)?;
+ if let Some(name) = name {
+ app_state.set_current_exercise_by_name(&name)?;
+ }
println!("{}", app_state.current_exercise().hint);
}
// Handled in an earlier match.