mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-27 21:51:33 +02:00
add --no-meta switch to avoid some redundant events for #78
This commit is contained in:
parent
524812028d
commit
d246114678
@ -14,6 +14,7 @@ args=(
|
|||||||
'(-k --kill)'{-k,--kill}'[Send SIGKILL to child processes (deprecated, use -s SIGKILL instead)]'
|
'(-k --kill)'{-k,--kill}'[Send SIGKILL to child processes (deprecated, use -s SIGKILL instead)]'
|
||||||
'(-n --no-shell)'{-n,--no-shell}'[Do not wrap command in ''sh -c'' resp. ''cmd.exe /C'']'
|
'(-n --no-shell)'{-n,--no-shell}'[Do not wrap command in ''sh -c'' resp. ''cmd.exe /C'']'
|
||||||
'--no-environment[Do not set WATCHEXEC_*_PATH environment variables for child process]'
|
'--no-environment[Do not set WATCHEXEC_*_PATH environment variables for child process]'
|
||||||
|
'--no-meta[Ignore metadata changes]'
|
||||||
'(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]'
|
'(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]'
|
||||||
'(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]'
|
'(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]'
|
||||||
'(-V --version)'{-V,--version}'[Prints version information]'
|
'(-V --version)'{-V,--version}'[Prints version information]'
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
<dt><code>-f</code>, <code>--filter</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that do not match <var>pattern</var>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <var>command</var>.</p></dd>
|
<dt><code>-f</code>, <code>--filter</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that do not match <var>pattern</var>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <var>command</var>.</p></dd>
|
||||||
<dt><code>-s</code>, <code>--signal</code></dt><dd><p>Sends the specified signal (e.g. <code>SIGKILL</code>) to the child process. Defaults to <code>SIGTERM</code>.</p></dd>
|
<dt><code>-s</code>, <code>--signal</code></dt><dd><p>Sends the specified signal (e.g. <code>SIGKILL</code>) to the child process. Defaults to <code>SIGTERM</code>.</p></dd>
|
||||||
<dt><code>-n</code>, <code>--no-shell</code></dt><dd><p>Execute command directly, do not wrap it in <code>sh -c</code> resp. <code>cmd.exe /C</code>. This is especially useful in combination with <code>--signal</code>, as the signal is then send directly to the specified command. While <code>--no-shell</code> is a little more performant than the default, it prevents using shell-features like pipes and redirects.</p></dd>
|
<dt><code>-n</code>, <code>--no-shell</code></dt><dd><p>Execute command directly, do not wrap it in <code>sh -c</code> resp. <code>cmd.exe /C</code>. This is especially useful in combination with <code>--signal</code>, as the signal is then send directly to the specified command. While <code>--no-shell</code> is a little more performant than the default, it prevents using shell-features like pipes and redirects.</p></dd>
|
||||||
|
<dt><code>--no-meta</code></dt><dd><p>Ignore metadata changes</p></dd>
|
||||||
<dt><code>--no-environment</code></dt><dd><p>Do not set WATCHEXEC_*_PATH environment variables for child process.</p></dd>
|
<dt><code>--no-environment</code></dt><dd><p>Do not set WATCHEXEC_*_PATH environment variables for child process.</p></dd>
|
||||||
<dt><code>-i</code>, <code>--ignore</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that match <var>pattern</var>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.</p></dd>
|
<dt><code>-i</code>, <code>--ignore</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that match <var>pattern</var>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.</p></dd>
|
||||||
<dt><code>-w</code>, <code>--watch</code> <var>path</var></dt><dd><p>Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <var>command</var> to be executed.</p></dd>
|
<dt><code>-w</code>, <code>--watch</code> <var>path</var></dt><dd><p>Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <var>command</var> to be executed.</p></dd>
|
||||||
|
@ -28,6 +28,9 @@ Sends the specified signal (e.g. `SIGKILL`) to the child process. Defaults to `S
|
|||||||
* `-n`, `--no-shell`:
|
* `-n`, `--no-shell`:
|
||||||
Execute command directly, do not wrap it in `sh -c` resp. `cmd.exe /C`. This is especially useful in combination with `--signal`, as the signal is then send directly to the specified command. While `--no-shell` is a little more performant than the default, it prevents using shell-features like pipes and redirects.
|
Execute command directly, do not wrap it in `sh -c` resp. `cmd.exe /C`. This is especially useful in combination with `--signal`, as the signal is then send directly to the specified command. While `--no-shell` is a little more performant than the default, it prevents using shell-features like pipes and redirects.
|
||||||
|
|
||||||
|
* `--no-meta`:
|
||||||
|
Ignore metadata changes.
|
||||||
|
|
||||||
* `--no-environment`:
|
* `--no-environment`:
|
||||||
Do not set WATCHEXEC_*_PATH environment variables for child process.
|
Do not set WATCHEXEC_*_PATH environment variables for child process.
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ pub struct Args {
|
|||||||
/// Do not wrap the commands in a shell.
|
/// Do not wrap the commands in a shell.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub no_shell: bool,
|
pub no_shell: bool,
|
||||||
|
/// Ignore metadata changes.
|
||||||
|
#[builder(default)]
|
||||||
|
pub no_meta: bool,
|
||||||
/// Do not set WATCHEXEC_*_PATH environment variables for child process.
|
/// Do not set WATCHEXEC_*_PATH environment variables for child process.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub no_environment: bool,
|
pub no_environment: bool,
|
||||||
@ -210,6 +213,9 @@ where
|
|||||||
.help("Do not wrap command in 'sh -c' resp. 'cmd.exe /C'")
|
.help("Do not wrap command in 'sh -c' resp. 'cmd.exe /C'")
|
||||||
.short("n")
|
.short("n")
|
||||||
.long("no-shell"))
|
.long("no-shell"))
|
||||||
|
.arg(Arg::with_name("no-meta")
|
||||||
|
.help("Ignore metadata changes")
|
||||||
|
.long("no-meta"))
|
||||||
.arg(Arg::with_name("no-environment")
|
.arg(Arg::with_name("no-environment")
|
||||||
.help("Do not set WATCHEXEC_*_PATH environment variables for child process")
|
.help("Do not set WATCHEXEC_*_PATH environment variables for child process")
|
||||||
.long("no-environment"))
|
.long("no-environment"))
|
||||||
@ -308,6 +314,7 @@ where
|
|||||||
debug: args.is_present("verbose"),
|
debug: args.is_present("verbose"),
|
||||||
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_environment: args.is_present("no-environment"),
|
no_environment: args.is_present("no-environment"),
|
||||||
no_vcs_ignore: args.is_present("no-vcs-ignore"),
|
no_vcs_ignore: args.is_present("no-vcs-ignore"),
|
||||||
no_ignore: args.is_present("no-ignore"),
|
no_ignore: args.is_present("no-ignore"),
|
||||||
|
10
src/run.rs
10
src/run.rs
@ -134,7 +134,7 @@ where
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
debug!("Waiting for filesystem activity");
|
debug!("Waiting for filesystem activity");
|
||||||
let paths = wait_fs(&rx, &filter, args.debounce);
|
let paths = wait_fs(&rx, &filter, args.debounce, args.no_meta);
|
||||||
debug!("Paths updated: {:?}", paths);
|
debug!("Paths updated: {:?}", paths);
|
||||||
|
|
||||||
if !handler.on_update(&paths)? {
|
if !handler.on_update(&paths)? {
|
||||||
@ -282,7 +282,7 @@ pub fn run(args: Args) -> Result<()> {
|
|||||||
watch(&ExecHandler::new(args)?)
|
watch(&ExecHandler::new(args)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_fs(rx: &Receiver<Event>, filter: &NotificationFilter, debounce: u64) -> Vec<PathOp> {
|
fn wait_fs(rx: &Receiver<Event>, filter: &NotificationFilter, debounce: u64, no_meta: bool) -> Vec<PathOp> {
|
||||||
let mut paths = Vec::new();
|
let mut paths = Vec::new();
|
||||||
let mut cache = HashMap::new();
|
let mut cache = HashMap::new();
|
||||||
|
|
||||||
@ -291,6 +291,12 @@ fn wait_fs(rx: &Receiver<Event>, filter: &NotificationFilter, debounce: u64) ->
|
|||||||
|
|
||||||
if let Some(ref path) = e.path {
|
if let Some(ref path) = e.path {
|
||||||
let pathop = PathOp::new(path, e.op.ok(), e.cookie);
|
let pathop = PathOp::new(path, e.op.ok(), e.cookie);
|
||||||
|
if let Some(op) = pathop.op {
|
||||||
|
if no_meta && PathOp::is_meta(op) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore cache for the initial file. Otherwise, in
|
// Ignore cache for the initial file. Otherwise, in
|
||||||
// debug mode it's hard to track what's going on
|
// debug mode it's hard to track what's going on
|
||||||
let excluded = filter.is_excluded(path);
|
let excluded = filter.is_excluded(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user