todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.56k stars 713 forks source link

Ability to have pre/post hooks #224

Open gms8994 opened 7 years ago

gms8994 commented 7 years ago

I'd like the ability to have hooks that are triggered immediately before and after saving a new task (or updating an existing one, and possibly archiving one as well?). My use case for before saving a task is simple:

I want to be able to say t add This is a test task due:tomorrow, and have my pre-save hook look for due:tomorrow (or any other string I determine), and modify the task text before it gets written to todo.txt. Obviously, this only works for tasks added via todo.sh.

I'm willing to figure out how to do this myself, but if it's something the community doesn't want, I won't expend the energy :)

betsythefc commented 6 years ago

I think this can pretty easily be solved with an add-on. Say instead of typing in todo.sh add "NEW TASK", I could make an add-on that is todo.sh addf "NEW TASK due:tomorrow". I'm willing to write this if you'd like! I'll also take name suggestions as addf isn't very pretty looking.

Alternatively this could be made to work outside of todo.sh if you wanted to be creative by setting TOMORROW as a variable, and using that instead, so bash (or whatever shell) expands it before being written. Not sure how you'd keep the variable up to date, but that's just one other option.

betsythefc commented 6 years ago

https://github.com/betsythefc/add

@gms8994, I made this add-on, it replaces add. I think this should be done with the script and not an add-on longterm but I don't know the right way to implement (I am working on it).