summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2013-07-12 21:21:32 -0700
committerDan Mick <dan.mick@inktank.com>2013-07-12 21:42:30 -0700
commit089dfe8e9e98890f14bc824f7b877f209113e46e (patch)
tree666f5b76e05c1a1ec2504afe961f680f400acf2a
parentda4c749ad3ef452eb28b1ce32d5a14f4558da46a (diff)
downloadceph-089dfe8e9e98890f14bc824f7b877f209113e46e.tar.gz
ceph_argparse: ignore prefix mismatches, but quit if non-prefix
I don't know what I was thinking; this was always the right validation algorithm, and I broke it trying to simplify. Signed-off-by: Dan Mick <dan.mick@inktank.com>
-rw-r--r--src/pybind/ceph_argparse.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py
index 4f468940cdc..830667480d4 100644
--- a/src/pybind/ceph_argparse.py
+++ b/src/pybind/ceph_argparse.py
@@ -790,7 +790,7 @@ def validate(args, signature, partial=False):
# hm, but it was required, so quit
if partial:
return d
- raise ArgumentFormat('{0} not valid argument {1}: {2}'.format(str(myarg), desc, e))
+ raise e
# valid arg acquired. Store in dict, as a list if multivalued
if desc.N:
@@ -851,16 +851,16 @@ def validate_command(parsed_args, sigdict, args, verbose=False):
valid_dict = validate(args, sig)
found = cmd
break
+ except ArgumentPrefix:
+ # ignore prefix mismatches; we just haven't found
+ # the right command yet
+ pass
except ArgumentError as e:
# prefixes matched, but some other arg didn't;
- # this is interesting information if verbose
- if verbose:
- print >> sys.stderr, '{0}: invalid command'.\
- format(' '.join(args))
- print >> sys.stderr, '{0}'.format(e)
- print >> sys.stderr, "did you mean {0}?\n\t{1}".\
- format(concise_sig(sig), helptext)
- pass
+ # stop now, because we have the right command but
+ # some other input is invalid
+ print >> sys.stderr, "Invalid command: ", str(e)
+ return {}
if found:
break