Skip to content

Commit ae56cba

Browse files
authored
Merge pull request #846 from rust-lang/feat/add-more-watch-commands
feat: add more watch commands
2 parents 2476243 + 3352b5a commit ae56cba

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn main() {
264264

265265
fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>) {
266266
let failed_exercise_hint = Arc::clone(failed_exercise_hint);
267-
println!("Type 'hint' or open the corresponding README.md file to get help or type 'clear' to clear the screen.");
267+
println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here.");
268268
thread::spawn(move || loop {
269269
let mut input = String::new();
270270
match io::stdin().read_line(&mut input) {
@@ -276,6 +276,18 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>) {
276276
}
277277
} else if input.eq("clear") {
278278
println!("\x1B[2J\x1B[1;1H");
279+
} else if input.eq("quit") {
280+
println!("Bye!");
281+
std::process::exit(0);
282+
} else if input.eq("help") {
283+
println!("Commands available to you in watch mode:");
284+
println!(" hint - prints the current exercise's hint");
285+
println!(" clear - clears the screen");
286+
println!(" quit - quits watch mode");
287+
println!(" help - displays this help message");
288+
println!();
289+
println!("Watch mode automatically re-evaluates the current exercise");
290+
println!("when you edit a file's contents.")
279291
} else {
280292
println!("unknown command: {}", input);
281293
}

0 commit comments

Comments
 (0)