Show current exercise on hint command

This commit is contained in:
mo8it 2026-04-06 23:21:15 +02:00
parent 95499f18dd
commit f403d9e1b6
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,10 @@
## Unreleased
### Added
- Show the file link of the current exercise when running `rustlings hint`
### Fixed
- Fix integer overflow on big terminal widths [@gabfec](https://github.com/gabfec)

View File

@ -156,7 +156,15 @@ fn main() -> Result<ExitCode> {
if let Some(name) = name {
app_state.set_current_exercise_by_name(&name)?;
}
println!("{}", app_state.current_exercise().hint);
let current_exercise = app_state.current_exercise();
let mut stdout = io::stdout().lock();
stdout.write_all(b"Current exercise: ")?;
current_exercise.terminal_file_link(&mut stdout, app_state.emit_file_links())?;
stdout.write_all(b"\n\nHint:\n")?;
stdout.write_all(current_exercise.hint.as_bytes())?;
stdout.write_all(b"\n")?;
}
// Handled in an earlier match.
Some(Command::Init | Command::Dev(_)) => (),