Skip to content

Commit f403d9e

Browse files
committed
Show current exercise on hint command
1 parent 95499f1 commit f403d9e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Added
6+
7+
- Show the file link of the current exercise when running `rustlings hint`
8+
59
### Fixed
610

711
- Fix integer overflow on big terminal widths [@gabfec](https://github.com/gabfec)

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,15 @@ fn main() -> Result<ExitCode> {
156156
if let Some(name) = name {
157157
app_state.set_current_exercise_by_name(&name)?;
158158
}
159-
println!("{}", app_state.current_exercise().hint);
159+
160+
let current_exercise = app_state.current_exercise();
161+
let mut stdout = io::stdout().lock();
162+
stdout.write_all(b"Current exercise: ")?;
163+
current_exercise.terminal_file_link(&mut stdout, app_state.emit_file_links())?;
164+
165+
stdout.write_all(b"\n\nHint:\n")?;
166+
stdout.write_all(current_exercise.hint.as_bytes())?;
167+
stdout.write_all(b"\n")?;
160168
}
161169
// Handled in an earlier match.
162170
Some(Command::Init | Command::Dev(_)) => (),

0 commit comments

Comments
 (0)