]> khamidou — GitHub mirrors - liszt.git/commitdiff
added a batch-mode for adding entries and update README
authorkhamidou <khamidou@gmail.com>
Mon, 8 Feb 2010 09:30:11 +0000 (10:30 +0100)
committerkhamidou <khamidou@gmail.com>
Mon, 8 Feb 2010 09:30:11 +0000 (10:30 +0100)
README
liszt

diff --git a/README b/README
index 08c9ead7128f42db5c3cdd2ea1a53d9d380f9319..9bdfff4fc3ee6bc86213eb6cd9b1d5b4da27add3 100644 (file)
--- 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 278e25fe9deca1c4fc74272101d83b36376cf2d0..fda47db35be3f56012aff4a6d648c37ab4f26a5d 100755 (executable)
--- 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: