handle no params
This commit is contained in:
parent
e9a1dbca4b
commit
7b84d9b10a
1 changed files with 3 additions and 3 deletions
|
@ -36,18 +36,18 @@ def main():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('method', nargs=1, type=str)
|
parser.add_argument('method', nargs=1, type=str)
|
||||||
parser.add_argument('params', nargs="+")
|
parser.add_argument('params', nargs=argparse.REMAINDER, default=None)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
meth = args.method[0]
|
meth = args.method[0]
|
||||||
params = {}
|
params = {}
|
||||||
if args.params:
|
if args.params:
|
||||||
if len(args.params) != 1:
|
if len(args.params) > 1:
|
||||||
for i in args.params:
|
for i in args.params:
|
||||||
k, v = i.split('=')[0], i.split('=')[1:]
|
k, v = i.split('=')[0], i.split('=')[1:]
|
||||||
if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
v = ''.join(v)
|
v = ''.join(v)
|
||||||
params[k] = guess_type(v)
|
params[k] = guess_type(v)
|
||||||
else:
|
elif len(args.params) == 1:
|
||||||
try:
|
try:
|
||||||
params = json.loads(args.params[0])
|
params = json.loads(args.params[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in a new issue