You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar issue: having an argument whose name starts with an underscore crashes argh (because it tries to pass "--" / "---foo" to argparse). I think this could be instead a mechanism either for specifying arguments not available on the command line, or the underscore could be removed in case the user wants to define an option whose name would collide with a builtin or a keyword.
...in its current state, argh handles it this way:
$ python issue79.py -h
usage: issue79.py [-h] a_b _c_d [e_f [e_f ...]]
positional arguments:
a_b -
_c_d -
e_f -
optional arguments:
-h, --help show this help message and exit
$ python issue79.py hello world extra plus
hello
world
('extra', 'plus')
That is, argh doesn't crash and displays all positional argument names with underscore (which could be replaced with a hyphen, but at least it's consistent).
However, this small example does crash argh the way you described
@argh.dispatch_commanddefmain(_foo=5):
return_foo
Traceback:
Traceback (most recent call last):
File "[...]argh/argh/assembling.py", line 307, in set_default_command
action = parser.add_argument(*dest_or_opt_strings, **draft)
File "/usr/lib/python3.5/argparse.py", line 1316, in add_argument
kwargs = self._get_optional_kwargs(*args, **kwargs)
File "/usr/lib/python3.5/argparse.py", line 1466, in _get_optional_kwargs
raise ValueError(msg % option_string)
ValueError: dest= is required for options like '---foo'
I suggest that we keep these as separate issues. I'll probably need more time to check this and your patch.
Define
foo.py
asThen
While a minor issue, it seems more consistent if the
c_d
argument was printed asc-d
.The text was updated successfully, but these errors were encountered: