mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Make the exercise name option for the hint subcommand
This commit is contained in:
parent
daa090981a
commit
a2be6754bf
|
@ -63,10 +63,10 @@ enum Subcommands {
|
||||||
/// The name of the exercise
|
/// The name of the exercise
|
||||||
name: String,
|
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 {
|
Hint {
|
||||||
/// The name of the exercise
|
/// The name of the exercise
|
||||||
name: String,
|
name: Option<String>,
|
||||||
},
|
},
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Dev(DevCommands),
|
Dev(DevCommands),
|
||||||
|
@ -162,7 +162,9 @@ fn main() -> Result<()> {
|
||||||
println!("The exercise {exercise_path} has been reset");
|
println!("The exercise {exercise_path} has been reset");
|
||||||
}
|
}
|
||||||
Some(Subcommands::Hint { name }) => {
|
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);
|
println!("{}", app_state.current_exercise().hint);
|
||||||
}
|
}
|
||||||
// Handled in an earlier match.
|
// Handled in an earlier match.
|
||||||
|
|
Loading…
Reference in a new issue