terminal_velocity icon indicating copy to clipboard operation
terminal_velocity copied to clipboard

Adding hook feature

Open ghost opened this issue 10 years ago • 6 comments
trafficstars

to execute external scripts when special events occur.

It can be use to execute pandoc or asciidoc after editing a note for example. This first version has only post hook script which is executed after the editor closing

ghost avatar Feb 10 '15 18:02 ghost

Hi @intru91 , this sounds awesome. A hook feature would also be good for calling a vcs like git to version your notes. I'll get round to merging this asap (at the weekend, or next week)

seanh avatar Feb 12 '15 10:02 seanh

Thanks @intru91, I added a couple of small things that I'd like you to fix.

There's also a couple of slightly bigger things:

Would you mind changing the approach slightly? Rather than a --hooks argument that takes JSON, I'd prefer a --post-hook argument that just takes a simple command to execute as argument (the command could be a path to a script file or just a command). This avoids bringing JSON into it, so keeps it simpler. When/if we add more hooks, we'll add more --*-hook arguments.

I think it'd also be nice to add some documentation (in the help text for the --post-hook argument maybe) explaining what the post hook is, i.e. that it gets executed after leaving the editor and returning to tv (and it looks like it always gets executed, even if the file wasn't edited, which is fine but worth a mention in the help text).

seanh avatar Feb 18 '15 21:02 seanh

Hi @seanh, thank you for the feedback !

I'll fix the typos.

For if hook in self.hooks != "", nice catch, it was a old code i left hanging ... . I'll replace it by if hook in self.hooks and ...

As for the user interface, JSON was a convenient way of getting data in the internal of terminal_velocity but was really bad for the user (hard to get right from the shell and exposing the internal data structures....). I actually intended to change the interface to a similar one that you described. I'll work on it and give you a feedback when i'll have something satisfying.

ghost avatar Feb 19 '15 09:02 ghost

Thanks! Looking forward to it

seanh avatar Feb 19 '15 11:02 seanh

Hi @seanh,

I'm pushed two new commit on my branch to apply the changes that you suggested.

ghost avatar Mar 12 '15 10:03 ghost

@intru91 This looks great. It has merge conflicts with the current master branch. Can you either pull master into your branch or rebase your branch on master (whichever you prefer) and solve the merge conflicts?

seanh avatar Mar 14 '15 19:03 seanh