]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch
implement notmuch dump and Messages.len()
[notmuch] / notmuch
diff --git a/notmuch b/notmuch
index 6f002aac749434f686257d58f692dcf113a3410c..172464c10bc3009383aac01a01db4f5990281ec1 100755 (executable)
--- a/notmuch
+++ b/notmuch
@@ -115,6 +115,17 @@ if __name__ == '__main__':
        #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
@@ -124,9 +135,17 @@ if __name__ == '__main__':
          querystr = quote_query_line(sys.argv[2:])
          logging.debug("search-term "+querystr)
          db = Database()
-         m  = Query(db,querystr).search_messages()
+         q  = Query(db,querystr)
+         #TODO: notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
+         m = q.search_messages()
          print("\n".join([t for t in m.collect_tags()]))
 
+   elif sys.argv[1] == 'dump':
+      db = Database()
+      msgs = Query(db,'').search_messages()
+      for msg in msgs:
+         print("%s (%s)" % (msg.get_message_id(), msg.get_tags()))
+
    else:
        # unknown command
        print "Error: Unknown command '%s' (see \"notmuch help\")" % sys.argv[1]
@@ -142,10 +161,6 @@ 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.