eradman/entr

Feature request: provide a way to debounce triggers

jaresty opened this issue · 8 comments

It would be really cool if there were some way to debounce triggers. Imagine that you are making lots of quick changes to several files and you want to do something when those files change that is expensive, like uploading to a server. It would be nice if you could set a debounce of say 5 seconds that would queue up and trigger after 5 seconds had passed, passing all files that had changed in that time.

What do you think?

I could use a concrete example to see how a delay to consolidate events would help. You can always add your own delay, but my intuition is that this is not the best solution!

entr -c -s 'sleep 5; ./run.sh'

It's not just a delay that I'm looking for- I also want it to aggregate the results. Here's a concrete example.

Imagine that I'm changing files a, b, and c in quick succession and then I want to trigger an upload to a server.

Currently, entry will trigger three times - once for each file.

What I'd like is for it to trigger once and pass all three files as arguments to the command I provide.

Does that make sense?

That makes sense, except entr does consolidate events that occur while executing a command. (Actually it drops them, but same effect.)

Try this

touch a b c
ls a b c | entr -p -s 'sleep 6; echo files changed; ls -l a b c'

Then in a second window update these files

for f in a b c; do date > $f; sleep1; done

You should see that the utility was only executed once

I'd like /_ to be replaced with all three files - is that already possible?

No /_ can't be used for this purpose. It's a fair question though, see my answer in #67 (comment)

I see... so the idea would be to use entr to trigger and then make to trigger based on things that changed. I think that could work.

Excactly. The design of entr is entirely based on detecting conditions that should trip and execution. This means it reopen files that were replaced (so that it can watch them), but it also discarding events that it consideres to be redundant.

I feel stronly that keeping track of things that have changed or are out of date is the responsibility of other tools. Although I do wish tools such as make was easier to use...

Understood. Thank you!