]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch
implement message counting
[notmuch] / notmuch
diff --git a/notmuch b/notmuch
index 6f002aac749434f686257d58f692dcf113a3410c..56f961b47d581f68172d2e9114b9190d6ff7a10d 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