Adding ToDos to Wunderlist via Fish Command line
(With human readable dates and autocompletion!)
Wunderlist is good GUI tool when you need todo organization, sharing and access from multiple devices. But for speed I want to add todos via command line, and allow scripts to do that for me.
If you Google "Wunderlist CLI", you will get solutions on Ruby and Nodejs. Nope, does not sound right for small CLI utility. Found good one written in Go - wl, but it intended as raw API, and there could be some user friendly improvements. For example you need to address lists via numeric id, and have to write date in defined format.
So I've created wrapper to make it more quick and convenient to use. Works like that (with tab completion and autosuggestions):
todo buy raspberry pi --life --on next monday todo do code review --work --star todo --work meet customer --on jan 7 todo visit mars --goals --on 2020-01-01 todo return books --on 3 days
Wrapper is written in Fish, because I wanted to try its syntax. Fish scripts are less bulky and more readable than Bash ones, but argument parsing is still a bother. So I've used lazy approach - check argument string for words using
contains. Then remove all words starting with "--" by regexp. In my opinion result looks more clean.
I've also used lazy (but universal) approach to generate argument completion - search script source for strings starting with "--" and add them to Fish completion as arguments for
todo command. Fish autosuggestions works greatly in this case - if you ever typed routine todo, fish will suggest completion next time.
Did you know that GNU Date understand human readable dates
date --date="next Friday"? Cool! So script assumes everything after
--on argument is date, so make sure it goes last in cmd. If
date fails to interpret date it will save todo as todays with date in title, so you will be able to correclty set it manually later.
For installation read script header