Skip to content

Commit

Permalink
Merge pull request #1480 from smlavine/main
Browse files Browse the repository at this point in the history
feat: Add "!" command to `rustlings watch`
  • Loading branch information
shadows-withal committed Apr 18, 2023
2 parents 9fc336c + a4a5691 commit 0dc9c33
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,21 @@ fn spawn_watch_shell(
println!("Bye!");
} else if input.eq("help") {
println!("Commands available to you in watch mode:");
println!(" hint - prints the current exercise's hint");
println!(" clear - clears the screen");
println!(" quit - quits watch mode");
println!(" help - displays this help message");
println!(" hint - prints the current exercise's hint");
println!(" clear - clears the screen");
println!(" quit - quits watch mode");
println!(" !<cmd> - executes a command, like `!rustc --explain E0381`");
println!(" help - displays this help message");
println!();
println!("Watch mode automatically re-evaluates the current exercise");
println!("when you edit a file's contents.")
} else if let Some(cmd) = input.strip_prefix('!') {
let parts: Vec<&str> = cmd.split_whitespace().collect();
if parts.is_empty() {
println!("no command provided");
} else if let Err(e) = Command::new(parts[0]).args(&parts[1..]).status() {
println!("failed to execute command `{}`: {}", cmd, e);
}
} else {
println!("unknown command: {input}");
}
Expand Down

0 comments on commit 0dc9c33

Please sign in to comment.