mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Merge pull request #180 from nindoja/add_changes_option
Add --changes-only option to only print path change information.
This commit is contained in:
commit
5e4af976de
@ -54,6 +54,9 @@ pub struct Args {
|
|||||||
/// Debug messages are printed via debug! so configure your logger appropriately instead.
|
/// Debug messages are printed via debug! so configure your logger appropriately instead.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub debug: bool,
|
pub debug: bool,
|
||||||
|
/// Change messages are printed via info! so configure your logger appropriately instead.
|
||||||
|
#[builder(default)]
|
||||||
|
pub changes: bool,
|
||||||
/// Run the commands right after starting.
|
/// Run the commands right after starting.
|
||||||
#[builder(default = "true")]
|
#[builder(default = "true")]
|
||||||
pub run_initially: bool,
|
pub run_initially: bool,
|
||||||
@ -178,6 +181,9 @@ where
|
|||||||
.help("Print debugging messages to stderr")
|
.help("Print debugging messages to stderr")
|
||||||
.short("v")
|
.short("v")
|
||||||
.long("verbose"))
|
.long("verbose"))
|
||||||
|
.arg(Arg::with_name("changes")
|
||||||
|
.help("Only print path change information. Overridden by --verbose")
|
||||||
|
.long("changes-only"))
|
||||||
.arg(Arg::with_name("filter")
|
.arg(Arg::with_name("filter")
|
||||||
.help("Ignore all modifications except those matching the pattern")
|
.help("Ignore all modifications except those matching the pattern")
|
||||||
.short("f")
|
.short("f")
|
||||||
@ -314,6 +320,7 @@ where
|
|||||||
restart: args.is_present("restart"),
|
restart: args.is_present("restart"),
|
||||||
debounce,
|
debounce,
|
||||||
debug: args.is_present("verbose"),
|
debug: args.is_present("verbose"),
|
||||||
|
changes: args.is_present("changes"),
|
||||||
run_initially: !args.is_present("postpone"),
|
run_initially: !args.is_present("postpone"),
|
||||||
no_shell: args.is_present("no-shell"),
|
no_shell: args.is_present("no-shell"),
|
||||||
no_meta: args.is_present("no-meta"),
|
no_meta: args.is_present("no-meta"),
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -6,17 +6,20 @@ use watchexec::{cli, error, run};
|
|||||||
|
|
||||||
fn main() -> error::Result<()> {
|
fn main() -> error::Result<()> {
|
||||||
let args = cli::get_args()?;
|
let args = cli::get_args()?;
|
||||||
init_logger(args.debug);
|
|
||||||
|
if args.debug {
|
||||||
|
init_logger(log::LevelFilter::Debug);
|
||||||
|
} else if args.changes {
|
||||||
|
init_logger(log::LevelFilter::Info);
|
||||||
|
} else {
|
||||||
|
init_logger(log::LevelFilter::Warn);
|
||||||
|
}
|
||||||
|
|
||||||
run(args)
|
run(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logger(debug: bool) {
|
fn init_logger(level: log::LevelFilter) {
|
||||||
let mut log_builder = env_logger::Builder::new();
|
let mut log_builder = env_logger::Builder::new();
|
||||||
let level = if debug {
|
|
||||||
log::LevelFilter::Debug
|
|
||||||
} else {
|
|
||||||
log::LevelFilter::Warn
|
|
||||||
};
|
|
||||||
|
|
||||||
log_builder
|
log_builder
|
||||||
.format(|buf, r| writeln!(buf, "*** {}", r.args()))
|
.format(|buf, r| writeln!(buf, "*** {}", r.args()))
|
||||||
|
@ -119,7 +119,7 @@ where
|
|||||||
loop {
|
loop {
|
||||||
debug!("Waiting for filesystem activity");
|
debug!("Waiting for filesystem activity");
|
||||||
let paths = wait_fs(&rx, &filter, args.debounce, args.no_meta);
|
let paths = wait_fs(&rx, &filter, args.debounce, args.no_meta);
|
||||||
debug!("Paths updated: {:?}", paths);
|
info!("Paths updated: {:?}", paths);
|
||||||
|
|
||||||
if !handler.on_update(&paths)? {
|
if !handler.on_update(&paths)? {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user