Could we let the command know which file changed? wendy does this by setting an environment variable ($WENDY_INODE
), which is a nice solution that avoids argument positional issues.
I don't know Rust, so I don't know if this is acceptable; however, it appears to work:
diff --git a/src/main.rs b/src/main.rs index 75b829b..f731ea6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn main() { // Spawn command let status = Command::new(program) + .env("EWATCH_INODE", path) .args(arguments) .status() .expect("Failed to execute command");
I think it's a nice solution. I would prefer a more precise variable name though, as inode is a name of a whole structure and we are only passing the file path. Maybe
EWATCH_FILE_PATH
?In v2 I plan to add a
find
-like CLI, so it would be possible to do something likeewatch '*' -c echo File '{}' changed
. I didn't have a lot of time recently, so that branch is pretty much stale for now, but hopefully I will have more time in the next week.
Awesome, thanks for accepting.
I will leave this issue open, until I add it to the 2.0 branch