From: Dan Mick Date: Sat, 13 Jul 2013 04:21:32 +0000 (-0700) Subject: ceph_argparse: ignore prefix mismatches, but quit if non-prefix X-Git-Tag: v0.67-rc1~59^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=089dfe8e9e98890f14bc824f7b877f209113e46e;p=ceph.git 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 --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 4f468940cdc7..830667480d4f 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