mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-05-15 17:58:44 +00:00
Show file link on reset command
This commit is contained in:
parent
f403d9e1b6
commit
695f927893
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Show the file link of the current exercise when running `rustlings hint`
|
- Show the file link of the current exercise when running `rustlings hint` and `rustlings reset`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@ -334,12 +334,10 @@ impl AppState {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_current_exercise(&mut self) -> Result<&str> {
|
pub fn reset_current_exercise(&mut self) -> Result<()> {
|
||||||
self.set_pending(self.current_exercise_ind)?;
|
self.set_pending(self.current_exercise_ind)?;
|
||||||
let exercise = self.current_exercise();
|
let exercise = self.current_exercise();
|
||||||
self.reset(self.current_exercise_ind, exercise.path)?;
|
self.reset(self.current_exercise_ind, exercise.path)
|
||||||
|
|
||||||
Ok(exercise.path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the exercise by index and return its name.
|
// Reset the exercise by index and return its name.
|
||||||
|
|||||||
@ -149,8 +149,13 @@ fn main() -> Result<ExitCode> {
|
|||||||
}
|
}
|
||||||
Some(Command::Reset { name }) => {
|
Some(Command::Reset { name }) => {
|
||||||
app_state.set_current_exercise_by_name(&name)?;
|
app_state.set_current_exercise_by_name(&name)?;
|
||||||
let exercise_path = app_state.reset_current_exercise()?;
|
app_state.reset_current_exercise()?;
|
||||||
println!("The exercise {exercise_path} has been reset");
|
|
||||||
|
let current_exercise = app_state.current_exercise();
|
||||||
|
let mut stdout = io::stdout().lock();
|
||||||
|
stdout.write_all(b"The exercise ")?;
|
||||||
|
current_exercise.terminal_file_link(&mut stdout, app_state.emit_file_links())?;
|
||||||
|
stdout.write_all(b" has been reset\n")?;
|
||||||
}
|
}
|
||||||
Some(Command::Hint { name }) => {
|
Some(Command::Hint { name }) => {
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user