]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch
notmuch: fix to use new Query.SORT enum
[notmuch] / notmuch
diff --git a/notmuch b/notmuch
index 6f002aac749434f686257d58f692dcf113a3410c..2ddd9ffc52911da15490fe5a741c20e86bcfa72a 100755 (executable)
--- a/notmuch
+++ b/notmuch
@@ -111,10 +111,34 @@ if __name__ == '__main__':
        if len(sys.argv) == 2: print HELPTEXT
        else: print "Not implemented"
 
+   elif sys.argv[1] == 'show':
+      db = Database()
+      if len(sys.argv) == 2:
+         #no further search term
+         querystr=''
+      else:
+         #mangle arguments wrapping terms with spaces in quotes
+         querystr = quote_query_line(sys.argv[2:])
+      logging.debug("show "+querystr)
+      m = Query(db,querystr).search_messages()
+      for msg in m:
+         print(msg.format_as_text())
+
    elif sys.argv[1] == 'new':
        #TODO: handle --verbose
        print "Not implemented."
 
+   elif sys.argv[1] == 'count':
+      db = Database()
+      if len(sys.argv) == 2:
+         #no further search term
+         querystr=''
+      else:
+         #mangle arguments wrapping terms with spaces in quotes
+         querystr = quote_query_line(sys.argv[2:])
+      logging.debug("count "+querystr)
+      print(len(Query(db,querystr).search_messages()))
+
    elif sys.argv[1] == 'search-tags':
       if len(sys.argv) == 2:
          #no further search term
@@ -127,6 +151,15 @@ if __name__ == '__main__':
          m  = Query(db,querystr).search_messages()
          print("\n".join([t for t in m.collect_tags()]))
 
+   elif sys.argv[1] == 'dump':
+      #TODO: implement "dump <filename>"
+      db = Database()
+      q = Query(db,'')
+      q.set_sort(Query.SORT.MESSAGE_ID)
+      m = q.search_messages()
+      for msg in m:
+         print("%s (%s)" % (msg.get_message_id(), msg.get_tags()))
+
    else:
        # unknown command
        print "Error: Unknown command '%s' (see \"notmuch help\")" % sys.argv[1]
@@ -135,31 +168,8 @@ if __name__ == '__main__':
    #TODO: implement
    """
 search [options...] <search-terms> [...]
-
-       Search for messages matching the given search terms.
-
 show   <search-terms> [...]
-
-       Show all messages matching the search terms.
-
-count  <search-terms> [...]
-
-       Count messages matching the search terms.
-
 reply  [options...] <search-terms> [...]
-
-       Construct a reply template for a set of messages.
-
 tag    +<tag>|-<tag> [...] [--] <search-terms> [...]
-
-       Add/remove tags for all messages matching the search terms.
-
-dump   [<filename>]
-
-       Create a plain-text dump of the tags for each message.
-
 restore        <filename>
-       search-tags     [<search-terms> [...] ]
-
-               List all tags found in the database or matching messages.
    """