mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
nmbug-status: add support for querying the search views
Make it easy for scripts to read the views and corresponding searches.
This commit is contained in:
parent
1c450ec5fa
commit
73fcfa861c
1 changed files with 14 additions and 2 deletions
|
@ -13,6 +13,7 @@ import urllib
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
|
@ -20,9 +21,10 @@ import subprocess
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--text', help='output plain text format',
|
parser.add_argument('--text', help='output plain text format',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
|
||||||
parser.add_argument('--config', help='load config from given file')
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -46,6 +48,16 @@ else:
|
||||||
|
|
||||||
config = json.load(fp)
|
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:
|
if args.text:
|
||||||
output_format = 'text'
|
output_format = 'text'
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue