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.
If you have rust installed on your machine:
cargo install ifft
Otherwise, check releases for downloads.
Create a config file (ifft.toml
) in a directory (let's say ~/ifft-test
):
```toml [[ifft]]
if = "*/" then = "echo hello, world." ```
Run ifft
with the directory containing your config as the argument:
ifft ~/ifft-test
.
You'll see the following output, which indicates that ifft
found your config
file:
Found config: "~/ifft-test/ifft.toml"
In later examples, we'll see that multiple config files can be embedded throughout the directory tree.
Now let's create a file that will trigger ifft
: touch ~/ifft-test/test1
You'll see the following output:
[2019-05-12 14:55:57Z] Event: Create("~/ifft-test/test1")
Match from config in: "~/ifft-test"
Matched if-cond: "**/*"
[2019-05-12 14:55:57Z] Execute: "echo hello, world." from "~/ifft-test"
Exit code: 0
Stdout:
hello, world.
Stderr:
As you can see, triggers report the match condition and the exit code, stdout, and stderr of the triggered command.
That's it. ifft
simply listens for file changes and takes action.
Here's a more complex ifft
config that would be in a folder such as ~/src
with sub-folders my-c-prog
and my-rust-prog
:
```toml
not = [ "~", ".swp", ]
[[ifft]]
if = "my-c-prog/*/.{c,h}" then = "make" working_dir = "my-c-prog"
[[ifft]] if = "my-rust-prog/*/.{rs,toml}"
not = ["my-rust-prog/target/*"] then = "cargo build" working_dir = "my-rust-prog"
[[ifft]] if = "*"
then = "cp -R {{}} ."
working_dir = "/tmp" ```
The second ifft
condition could be moved into a new ifft.toml
in the
my-rust-prog
folder. For equivalent functionality, the contents would be:
[[ifft]]
if = "**/*.{rs,toml}"
not = ["target/*"]
then = "cargo build"
This allows you to distribute config files all over, which has the advantage of keeping them small and relevant to the folder they're in.
If you want to automatically trigger iffts on start without any file event,
use the -r
flag. The argument will trigger any iffts with matching names. For
example, running ifft ~/ifft-test -r build
will match:
toml
[[ifft]]
name = "build"
if = "**/*.{rs,toml}"
not = ["target/*"]
then = "cargo build"
This is useful to ensure that projects are built on boot without having to wait for a file event.
You can also use the -q
flag to quit after the -r
flag triggers have
completed. This can be used to initiate a one-time build or clean without
listening for changes afterwards.
Another strategy is to omit the if
condition which means it can only be
triggered on start with the -r
flag.
toml
file.if
and not
conditions.not
filtering and per-trigger not
filtering.if
, then
is only executed if an event
was triggered after the last time then
was executed.Tested on Linux and OS X. Untested elsewhere.
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.
.gitignore
parsing support.