Skip to content

Commit 162d061

Browse files
committed
Fix cli so it will accept positional arguments for service methods the require them. sunlight.congress:locate_legislators_by_lat_lon for example. Lat/lon args provided as comma-separated pair works as well.
1 parent d7e3e44 commit 162d061

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sunlight/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import sys
3+
import itertools
34

45
from clint import args
56
import sunlight
@@ -19,7 +20,9 @@ def main():
1920
(g[0][2:], g[1].get(0)) for g in args.grouped.items()[1:] if
2021
g[0].startswith('--')
2122
])
22-
resp = getattr(service, args.get(1))(**params)
23+
fn_args = [g.split(',') for g in args.grouped.get('_')[2:]]
24+
fn_args = list(itertools.chain.from_iterable(fn_args))
25+
resp = getattr(service, args.get(1))(*fn_args, **params)
2326
sys.stdout.write(json.dumps(resp, indent=2) + '\n')
2427

2528
else:

0 commit comments

Comments
 (0)