From b4ffdff02604fd407006b773feda4db1c4e05888 Mon Sep 17 00:00:00 2001 From: Zoey Llewellyn Hewll Date: Sat, 20 Jul 2024 11:45:04 +0800 Subject: [PATCH] add --quiet flag to `watch` command --- crates/nu-command/src/filesystem/watch.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/filesystem/watch.rs b/crates/nu-command/src/filesystem/watch.rs index c9817de250..e6d86357b8 100644 --- a/crates/nu-command/src/filesystem/watch.rs +++ b/crates/nu-command/src/filesystem/watch.rs @@ -61,6 +61,7 @@ impl Command for Watch { "Watch all directories under `` recursively. Will be ignored if `` is a file (default: true)", Some('r'), ) + .switch("quiet", "Hide the initial status message (default: false)", Some('q')) .switch("verbose", "Operate in verbose mode (default: false)", Some('v')) .category(Category::FileSystem) } @@ -94,6 +95,8 @@ impl Command for Watch { let verbose = call.has_flag(engine_state, stack, "verbose")?; + let quiet = call.has_flag(engine_state, stack, "quiet")?; + let debounce_duration_flag: Option> = call.get_flag(engine_state, stack, "debounce-ms")?; let debounce_duration = match debounce_duration_flag { @@ -161,7 +164,9 @@ impl Command for Watch { // need to cache to make sure that rename event works. debouncer.cache().add_root(&path, recursive_mode); - eprintln!("Now watching files at {path:?}. Press ctrl+c to abort."); + if !quiet { + eprintln!("Now watching files at {path:?}. Press ctrl+c to abort."); + } let mut closure = ClosureEval::new(engine_state, stack, closure);