From fb80427ec1cc8ba61fe75bb45819baa857674ee6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 22 May 2021 13:00:24 -0400 Subject: [PATCH] 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 --- src/pybind/ceph_argparse.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index e401ef0c342..dd70156c97e 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") -- 2.39.5