Articles Github Feed

Entree

What is it?

Entree is something I brewed up in my spare time over the course of 2 evenings.

It utilises the entr watcher which if you haven’t heard of it, is a very simple and lightweight way to watch for changes and do something on change.

Entree was partially inspired by funzzy. I saw that they were versioning their watchers and realised that’s something I wanted too, but I wanted it with entr.

While I do have a slight love for Rust (what funzzy is written in), I didn’t want to use yet another reinvention of the wheel. entr has been around for a while and is battle-tested. Besides that, my attempts with funzzy were not so funzzy.

How does it work?

It has a file named an .entreerc which follows a very strict format of

[watcher-name]
find . | entr stuff

i.e.

The watcher name on one line, and the command on the next line.

My .entreerc looks like this, it’s very small because I don’t actually use many watchers…heh.

[mort-test-integration]
rg '' -l | entr npm run build && mort -f test/fixtures/no-usages.css

[detect-dead-css]
ls ~/programs/mort/test/fixtures/*.css | entr mort -vvf /_

The code for entree is written in bash which allows some pretty beautiful things to happen. I get some nice tab-completion.

This was actually my first time making anything with tab-completion and it was much easier than I thought, I managed to get command completion and sub-command completion in,

a very easy installation process and of course, the powers of the shell!

One of the nicer things about using the shell for this is I automatically get arguments injected into the command, meaning that all of my watchers are now able to take command line arguments.

e.g.

[watcher-name]
find . | entr $2

Running this with:

entree watch watcher-name ls

Will execute ls on every change of the current directory, pretty neat and very modular.

Why would I ever want this?

If you constantly spin up the same watchers, and want to share them across machines, then you probably want a way of remembering your watchers, that’s what this is.