From 13d7d5722771bf8c4de7083dc0f964dfffcb318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 11 Dec 2021 01:12:25 +0100 Subject: feat(watcher): clear screen on each restart (#12613) This commit adds automatic clearing of terminal screen after restarting execution on file change. --- cli/file_watcher.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cli/file_watcher.rs') diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs index 84b30dfd2..b2d2ee15a 100644 --- a/cli/file_watcher.rs +++ b/cli/file_watcher.rs @@ -21,6 +21,7 @@ use tokio::select; use tokio::sync::mpsc; use tokio::time::sleep; +const CLEAR_SCREEN: &str = "\x1B[2J\x1B[1;1H"; const DEBOUNCE_INTERVAL: Duration = Duration::from_millis(200); struct DebouncedReceiver { @@ -90,6 +91,8 @@ where paths_to_watch, result, } => { + // Clear screen first + eprint!("{}", CLEAR_SCREEN); info!( "{} File change detected! Restarting!", colors::intense_blue("Watcher"), @@ -156,6 +159,10 @@ where } }; + // Clear screen first + eprint!("{}", CLEAR_SCREEN); + info!("{} {} started.", colors::intense_blue("Watcher"), job_name,); + loop { let watcher = new_watcher(&paths_to_watch, sender.clone())?; -- cgit v1.2.3