be pickier about keyword args and add a note about them in usage

This commit is contained in:
Mike McLean 2023-06-15 10:16:45 -04:00 committed by Tomas Kopecek
parent 65d0bbb897
commit 61675aec2f
2 changed files with 8 additions and 2 deletions

View file

@ -963,6 +963,7 @@ def handle_call(goptions, session, args):
usage = """\
usage: %prog call [options] <name> [<arg> ...]
<arg> values of the form NAME=VALUE are treated as keyword arguments
Note, that you can use global option --noauth for anonymous calls here"""
usage = textwrap.dedent(usage)
parser = OptionParser(usage=get_usage_str(usage))
@ -1016,11 +1017,14 @@ def handle_call(goptions, session, args):
if options.kwargs:
kw = parse_arg(options.kwargs)
kw_pat = re.compile(r'^([^\W0-9]\w*)=(.*)$')
# read the args
non_kw = []
for arg in args[1:]:
if arg.find('=') != -1:
key, value = arg.split('=', 1)
m = kw_pat.match(arg)
if m:
key, value = m.groups()
kw[key] = parse_arg(value)
else:
non_kw.append(parse_arg(arg))

View file

@ -22,6 +22,7 @@ class TestCall(utils.CliTestCase):
self.activate_session_mock = mock.patch('koji_cli.commands.activate_session').start()
self.error_format = """Usage: %s call [options] <name> [<arg> ...]
<arg> values of the form NAME=VALUE are treated as keyword arguments
Note, that you can use global option --noauth for anonymous calls here
(Specify the --help global option for a list of other help options)
@ -158,6 +159,7 @@ Note, that you can use global option --noauth for anonymous calls here
handle_call,
"""Usage: %s call [options] <name> [<arg> ...]
<arg> values of the form NAME=VALUE are treated as keyword arguments
Note, that you can use global option --noauth for anonymous calls here
(Specify the --help global option for a list of other help options)