mirror of
https://github.com/ceph/ceph
synced 2025-04-11 04:02:04 +00:00
ceph_argparse.py cleanup: simplify some code, error on unused args
Signed-off-by: Dan Mick <dan.mick@inktank.com>
This commit is contained in:
parent
a5621625e1
commit
2e2bc6d023
@ -516,7 +516,7 @@ class argdesc(object):
|
|||||||
if k.startswith('__') or k in internals:
|
if k.startswith('__') or k in internals:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# undo mods above
|
# undo modification from __init__
|
||||||
if k == 'n' and self.N:
|
if k == 'n' and self.N:
|
||||||
v = 'N'
|
v = 'N'
|
||||||
r += '{0}={1}, '.format(k,v)
|
r += '{0}={1}, '.format(k,v)
|
||||||
@ -527,7 +527,7 @@ class argdesc(object):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
if ((self.t == CephChoices and len(self.instance.strings) == 1)
|
if ((self.t == CephChoices and len(self.instance.strings) == 1)
|
||||||
or (self.t == CephPrefix)):
|
or (self.t == CephPrefix)):
|
||||||
s = '{0}'.format(str(self.instance))
|
s = str(self.instance)
|
||||||
else:
|
else:
|
||||||
s = '{0}({1})'.format(self.name, str(self.instance))
|
s = '{0}({1})'.format(self.name, str(self.instance))
|
||||||
if self.N:
|
if self.N:
|
||||||
@ -545,7 +545,7 @@ class argdesc(object):
|
|||||||
chunk = '<{0}>'.format(self.name)
|
chunk = '<{0}>'.format(self.name)
|
||||||
else:
|
else:
|
||||||
chunk = str(self.instance)
|
chunk = str(self.instance)
|
||||||
s = '{0}'.format(chunk)
|
s = chunk
|
||||||
if self.N:
|
if self.N:
|
||||||
s += ' [' + chunk + '...]'
|
s += ' [' + chunk + '...]'
|
||||||
if not self.req:
|
if not self.req:
|
||||||
@ -556,15 +556,7 @@ def concise_sig(sig):
|
|||||||
"""
|
"""
|
||||||
Return string representation of sig useful for syntax reference in help
|
Return string representation of sig useful for syntax reference in help
|
||||||
"""
|
"""
|
||||||
first = True
|
return ' '.join([d.helpstr() for d in sig])
|
||||||
s = ''
|
|
||||||
for d in sig:
|
|
||||||
if first:
|
|
||||||
first = False
|
|
||||||
else:
|
|
||||||
s += ' '
|
|
||||||
s += d.helpstr()
|
|
||||||
return s
|
|
||||||
|
|
||||||
def descsort(sh1, sh2):
|
def descsort(sh1, sh2):
|
||||||
"""
|
"""
|
||||||
@ -813,6 +805,8 @@ def validate(args, signature, partial=False):
|
|||||||
else:
|
else:
|
||||||
# if first CephPrefix or any other type, just set it
|
# if first CephPrefix or any other type, just set it
|
||||||
d[desc.name] = desc.instance.val
|
d[desc.name] = desc.instance.val
|
||||||
|
if myargs and not partial:
|
||||||
|
raise ArgumentError("unused arguments: " + str(myargs))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def validate_command(parsed_args, sigdict, args, verbose=False):
|
def validate_command(parsed_args, sigdict, args, verbose=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user