From: Sage Weil Date: Sat, 22 May 2021 17:00:24 +0000 (-0400) Subject: pybind/ceph_argparse: stop parsing when we run out of positional args X-Git-Tag: v17.1.0~1726^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb80427ec1cc8ba61fe75bb45819baa857674ee6;p=ceph.git pybind/ceph_argparse: stop parsing when we run out of positional args If we encouter an arg that is not a named flag/arg, and the next item in the command description is non-positional, then raise an 'unexpected argument' exception. Signed-off-by: Sage Weil --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index e401ef0c3428..dd70156c97ec 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -1196,6 +1196,10 @@ def validate(args: List[str], store_arg(kwarg_desc, d) continue + if not desc.positional: + # No more positional args! + raise ArgumentValid(f"Unexpected argument '{myarg}'") + # Don't handle something as a positional argument if it # has a leading "--" unless it's a CephChoices (used for # "--yes-i-really-mean-it")