From 724a7d2adc599bc53995d3e61d299d174314ffb9 Mon Sep 17 00:00:00 2001 From: Adi Vaknin Date: Thu, 23 Jul 2020 21:23:27 +0300 Subject: [PATCH] feat(cli): Added 'cls' command to 'watch' mode (#474) --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index aa67aca646..0e1291c340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,15 +143,18 @@ fn main() { fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); - println!("Type 'hint' to get help"); + println!("Type 'hint' to get help or 'clear' to clear the screen"); thread::spawn(move || loop { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_) => { - if input.trim().eq("hint") { + let input = input.trim(); + if input.eq("hint") { if let Some(hint) = &*failed_exercise_hint.lock().unwrap() { println!("{}", hint); } + } else if input.eq("clear") { + println!("\x1B[2J\x1B[1;1H"); } else { println!("unknown command: {}", input); }