I finally got around to rewriting my google tasks script (see previous posts here and here. The script has generated a fair amount of interest for this blog. After intending to do it for a while, I finally rewrote the program using the python module
optparse, which is intended for parsing command line options and arguments.
optparse is being deprecated in favor of
argparse, which has been back ported from python 3.x to 2.7. But, given that I tend to use Apple’s python distribution, which is 2.6.1 in Leopard and SnowLeopard, I opted for optparse.
One of the nice elements of
optparse is that it automates producing a help option for a command line program. In the spirit of the CLI, I rewrote the command options so that they are more
bash-like. I’ve also changed it a bit to better handle posts w/o due dates, blank posts, and subtasks.
Also, because of the awkwardness of sharing scripts through wordpress.com, I moved the source to github. I also put the script up there to post to wordpress.com using with markdown that I wrote about here. That one needs some work, though. Particularly handling ascii/unicode issues and with uploading images.
At any rate, the v0.2 of myTasks works thusly (assuming you have the script on your path and/or with an alias):
Usage: tasks [option] arg1 arg2 arg3
--version show program's version number and exit
-h, --help show this help message and exit
-l Lists all tasks. Takes no arguments
Adds new task. Pass the name of the task list and the
new task as arguments in double quotes. For example:
tasks -n Main "Add this task to the Main list."
-c Clears completed tasks from your lists. Takes no
Updates a designated task as completed. Pass the name
of the list and the number of the task. The number is
available by first listing tasks with the -l command.
For example: tasks -u Main 1. This command would mark
the first message on the Main list as completed.
Deletes a designated task. Pass the name of the list
and the number of the task. The number is available by
first listing tasks with the -l command. For example:
tasks -d Main 1. This command would delete the first
message from the Main list.
It does just about all I want to do with it. I’m going to add the option to output all lists, or a designated list, but that’s about it for now. Please feel free to fork on github and make a pull request to improve it.
Update 9-20-2011: I pushed v0.3 of myTasks to github this morning. The new version uses a different commandline parser, and adds functionality with task listing options, the ability to rename or delete Lists, and a bit more.