Skip to content

Commit 695f927

Browse files
committed
Show file link on reset command
1 parent f403d9e commit 695f927

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Added
66

7-
- Show the file link of the current exercise when running `rustlings hint`
7+
- Show the file link of the current exercise when running `rustlings hint` and `rustlings reset`
88

99
### Fixed
1010

src/app_state.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,10 @@ impl AppState {
334334
Ok(())
335335
}
336336

337-
pub fn reset_current_exercise(&mut self) -> Result<&str> {
337+
pub fn reset_current_exercise(&mut self) -> Result<()> {
338338
self.set_pending(self.current_exercise_ind)?;
339339
let exercise = self.current_exercise();
340-
self.reset(self.current_exercise_ind, exercise.path)?;
341-
342-
Ok(exercise.path)
340+
self.reset(self.current_exercise_ind, exercise.path)
343341
}
344342

345343
// Reset the exercise by index and return its name.

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ fn main() -> Result<ExitCode> {
149149
}
150150
Some(Command::Reset { name }) => {
151151
app_state.set_current_exercise_by_name(&name)?;
152-
let exercise_path = app_state.reset_current_exercise()?;
153-
println!("The exercise {exercise_path} has been reset");
152+
app_state.reset_current_exercise()?;
153+
154+
let current_exercise = app_state.current_exercise();
155+
let mut stdout = io::stdout().lock();
156+
stdout.write_all(b"The exercise ")?;
157+
current_exercise.terminal_file_link(&mut stdout, app_state.emit_file_links())?;
158+
stdout.write_all(b" has been reset\n")?;
154159
}
155160
Some(Command::Hint { name }) => {
156161
if let Some(name) = name {

0 commit comments

Comments
 (0)