snakeoil icon indicating copy to clipboard operation
snakeoil copied to clipboard

An equal sign is required before the argument's value

Open kuraga opened this issue 2 years ago • 3 comments

An equal sign is required before the argument's value.

For example, pkgcheck scan --help says:

  -c CHECK[,-CHECK,+CHECK,...], --checks CHECK[,-CHECK,+CHECK,...]
                        limit checks to run

but

pkgcheck scan --checks "-VisibilityCheck"
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/snakeoil/cli/arghparse.py", line 1248, in parse_known_args
    namespace, args = functor(parser, namespace, args)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pkgcheck/scripts/pkgcheck_scan.py", line 375, in _setup_scan
    namespace, _ = parser._parse_known_args(args, namespace)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/argparse.py", line 2114, in _parse_known_args
    start_index = consume_optional(start_index)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/argparse.py", line 2044, in consume_optional
    arg_count = match_argument(action, selected_patterns)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/argparse.py", line 2208, in _match_argument
    raise ArgumentError(action, msg)
argparse.ArgumentError: argument -c/--checks: expected one argument
pkgcheck scan: error: argument -c/--checks: expected one argument

while

pkgcheck scan --checks="-VisibilityCheck"

is OK.

pkgcheck 0.10.24 snakeoil 0.10.5

kuraga avatar May 24 '23 09:05 kuraga

Note that it's only when there's -value.

thesamesam avatar May 24 '23 09:05 thesamesam

I'm not sure if we can fix it, since this part of the behavior of argparse inside. I'm also not sure if I can fix the format it shows the help (notice that it doesn't mention the = format) since this also uses the builtin format.

arthurzam avatar May 27 '23 08:05 arthurzam