add --quiet flag to watch command

This commit is contained in:
Zoey Llewellyn Hewll 2024-07-20 11:45:04 +08:00
parent dbd60ed4f4
commit b4ffdff026

View File

@ -61,6 +61,7 @@ impl Command for Watch {
"Watch all directories under `<path>` recursively. Will be ignored if `<path>` 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<Spanned<i64>> =
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);