mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 23:50:03 -06:00
parameters: introduce cli_metavar keyword argument
Add new Param keyword argument cli_metavar to specify the stand-in for CLI option arguments in command help text. Uppercase class name is used by default. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
parent
4c7be74526
commit
98ede1b0e8
@ -1163,10 +1163,8 @@ class cli(backend.Executioner):
|
||||
kw['action'] = 'store_false'
|
||||
else:
|
||||
kw['action'] = 'store_true'
|
||||
elif isinstance(option, Enum):
|
||||
kw['metavar'] = list(str(x) for x in option.values)
|
||||
else:
|
||||
kw['metavar'] = option.__class__.__name__.upper()
|
||||
kw['metavar'] = option.cli_metavar
|
||||
|
||||
cli_name = to_cli(option.cli_name)
|
||||
option_names = ['--%s' % cli_name]
|
||||
|
@ -413,6 +413,7 @@ class Param(ReadOnly):
|
||||
('alwaysask', bool, False),
|
||||
('sortorder', int, 2), # see finalize()
|
||||
('option_group', unicode, None),
|
||||
('cli_metavar', str, None),
|
||||
|
||||
# The 'default' kwarg gets appended in Param.__init__():
|
||||
# ('default', self.type, None),
|
||||
@ -503,6 +504,9 @@ class Param(ReadOnly):
|
||||
if kw.get('cli_name') is None:
|
||||
kw['cli_name'] = self.name
|
||||
|
||||
if kw.get('cli_metavar') is None:
|
||||
kw['cli_metavar'] = self.__class__.__name__.upper()
|
||||
|
||||
if kw.get('label') is None:
|
||||
kw['label'] = FixMe(self.name)
|
||||
|
||||
@ -1514,6 +1518,7 @@ class Enum(Param):
|
||||
)
|
||||
|
||||
def __init__(self, name, *rules, **kw):
|
||||
kw['cli_metavar'] = str([str(v) for v in kw.get('values', tuple())])
|
||||
super(Enum, self).__init__(name, *rules, **kw)
|
||||
for (i, v) in enumerate(self.values):
|
||||
if type(v) not in self.allowed_types:
|
||||
|
Loading…
Reference in New Issue
Block a user