ifft-0.2.0 is not a library.
IF Filesystem-event Then (IFFT)

IF a filesystem event (create, write, remove, chmod) occurs in a watched folder that is not filtered out by an exclusion rule THEN execute a shell command.
Use this to watch for code changes to trigger: process restart; code compilation; or test run.
Installation
If you have rust installed on your machine:
cargo install ifft
Otherwise, check releases for downloads.
Usage
Create a config file (ifft_config.toml):
# The top-level folder to watch. Relative paths specified elsewhere will be
# relative to this folder. Supports ~ and env vars ($VAR).
= "~/src"
# Never trigger on a backup or swap file. (VIM specific)
= [
"*~",
"*.swp",
]
[[]]
# my-c-prog is a folder in ~/src
# If any .c or .h files change, recompile.
= "my-c-prog/**/*.{c,h}"
= "make"
= "my-c-prog"
[[]]
= "my-rust-prog/*"
# Ignore changes in the target folder to avoid recursive triggering.
= ["my-rust-prog/target/*"]
= "cargo build"
= "my-rust-prog"
# Contrived example to demonstrate other features.
[[]]
# Omitting the if condition -> trigger on all events under root.
# if =
# {{}} is substituted with the absolute path to the triggering file.
= "cp -R {{}} ."
# working_dir can be an absolute path.
= "/tmp"
Run ifft:
Output:
ifft is verbose for easy debugging. Triggers report the match condition and
the exit code, stdout, and stderr of the triggered command:
[2019-01-31 04:51:28Z] Event: Create("/home/ken/src/my-rust-prog/src/main.rs")
Matched if-cond: "my-rust-prog/*"
Executing: "cargo build" from "/home/ken/src/my-rust-prog"
Exit code: 0
Stdout:
Stderr:
Compiling my-rust-prog v0.1.0 (/home/ken/src/my-rust-prog)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
[2019-01-31 04:51:28Z] Event: Create("/home/ken/src/my-rust-prog/target/debug/incremental/my_rust_prog-1m194buzrsqka/s-f91jk9lg3a-wlnrr5.lock")
[2019-01-31 04:51:28Z] Event: Write("/home/ken/src/my-rust-prog/target/debug/deps/my_rust_prog-b5f4d74ed1175a94.d")
Features
- Configure with a
tomlfile. - Use glob patterns for
ifandnotconditions. rootas an absolute path independent fromifconditions as relative paths.rootsupports shell expansion:~and environment variables.- Global
notfiltering and per-triggernotfiltering. - Multiple events that trigger the same
ifare buffered and only trigger onethenexecution.
Platforms
Tested on Linux and OS X. Untested elsewhere.
Usage with VirtualBox Shared Folders
On the guest OS, VirtualBox Shared Folders do not generate filesystem event notifications. You'll need to use a separate filesystem event forwarder such as notify-forwarder.
Alternatives
- bazel for a serious incremental build system.
- watchexec is a more full-featured program.
- entr has a clean Unixy interface.
Todo
- [] Add
.gitignoreparsing support. - [] Flag to ignore hidden files.
- [] Flag to control verbosity of prints.
- [] Group events in quick succession together and trigger only once.
- [] Allow customization of type of FS events that trigger.
- [] Low priority: Compute the optimal path prefix for watching.
- [] Performance: Do not compile glob before each use. Current hack to make it easy to access the glob pattern string if an error occurs.