summaryrefslogtreecommitdiff
path: root/cli/file_watcher.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-12-11 01:12:25 +0100
committerGitHub <noreply@github.com>2021-12-11 01:12:25 +0100
commit13d7d5722771bf8c4de7083dc0f964dfffcb318a (patch)
tree2c1fb4c129d1e8bfe1622e55ef932aa10291f5da /cli/file_watcher.rs
parent11a2a3593df75ebbbf297f6ffadef8dd4eb166a3 (diff)
feat(watcher): clear screen on each restart (#12613)
This commit adds automatic clearing of terminal screen after restarting execution on file change.
Diffstat (limited to 'cli/file_watcher.rs')
-rw-r--r--cli/file_watcher.rs7
1 files changed, 7 insertions, 0 deletions
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())?;