]> git.notmuchmail.org Git - notmuch/commitdiff
nmbug-status: add support for querying the search views
authorJani Nikula <jani@nikula.org>
Mon, 1 Apr 2013 09:44:01 +0000 (12:44 +0300)
committerDavid Bremner <bremner@debian.org>
Sat, 6 Apr 2013 11:36:26 +0000 (08:36 -0300)
Make it easy for scripts to read the views and corresponding searches.

devel/nmbug/nmbug-status

index d08ca08dc86445ef8026a594669970df09ce533c..55f0d738f383781319ee4164f004ca5e78411853 100755 (executable)
@@ -13,6 +13,7 @@ import urllib
 import json
 import argparse
 import os
+import sys
 import subprocess
 
 # parse command line arguments
@@ -20,9 +21,10 @@ import subprocess
 parser = argparse.ArgumentParser()
 parser.add_argument('--text', help='output plain text format',
                     action='store_true')
-
 parser.add_argument('--config', help='load config from given file')
-
+parser.add_argument('--list-views', help='list views',
+                    action='store_true')
+parser.add_argument('--get-query', help='get query for view')
 
 args = parser.parse_args()
 
@@ -46,6 +48,16 @@ else:
 
 config = json.load(fp)
 
+if args.list_views:
+    for view in config['views']:
+        print view['title']
+    sys.exit(0)
+elif args.get_query != None:
+    for view in config['views']:
+        if args.get_query == view['title']:
+            print ' and '.join(view['query'])
+    sys.exit(0)
+
 if args.text:
     output_format = 'text'
 else: