From: khamidou Date: Mon, 8 Feb 2010 09:30:11 +0000 (+0100) Subject: added a batch-mode for adding entries and update README X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=82e6f1eb67571587c1fba430a6b7e05b1e103c90;p=liszt.git added a batch-mode for adding entries and update README --- diff --git a/README b/README index 08c9ead..9bdfff4 100644 --- a/README +++ b/README @@ -33,5 +33,21 @@ Basic Usage * Removing a list - list remove "my list" - list remove "my list" entry_index + liszt remove "my list" + liszt remove "my list" entry_index + +* Adding entries in batch mode + + liszt add "my list" + + This will fire-up the text editor defined in the EDITOR environment variable. The file format is a bit peculiar : each entry is separated by a '+' + symbol. After adding the entries, save and quit. Liszt will automatically add the entries to your todoliszt.com list. + +* Updating the entries of a list + + liszt update "my list" + + Similarly to the 'add' option, update will open up a text editor with the content of the list "my list". The file format is similar to the one used with + the 'add' option : each entry begins with a + symbol. The contents of an entry are (in this order) : the text of an entry, a boolean indicating if it's + been done or not and a timestamp. + After saving and quitting, the list is automatically updated. \ No newline at end of file diff --git a/liszt b/liszt index 278e25f..fda47db 100755 --- a/liszt +++ b/liszt @@ -157,6 +157,7 @@ class CommandParser(object): "show" : self.parse_show, "s" : self.parse_show, "update" : self.parse_update, + "add" : self.parse_add, } if args[0] in self.dispatch: @@ -262,6 +263,32 @@ class CommandParser(object): os.unlink(filename) + def parse_add(self, args): + listname = "" + + if len(args) == 0: + bailout("liszt add listname ") + + listname = args[0] + + fd, filename = tempfile.mkstemp() + + editor = os.getenv("EDITOR") + os.system(editor + " " + filename) + os.close(fd) + + # Now, reopen the fd, as a python file handle. + fd = open(filename) + lines = fd.read().split('+') + + for i in range(len(lines)): + # fields = lines[i].split("\t") FIXME: add support for different fields on a line. + + if lines[i] != '': + session.create_list_entry(listname, lines[i].rstrip().lstrip()) + + os.unlink(filename) + if __name__ == "__main__": if len(sys.argv) <= 1: