mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
Add a one-character option for parameters
This commit is contained in:
parent
c21e003cdf
commit
d6e1e15fcd
@ -739,7 +739,10 @@ class cli(backend.Executioner):
|
||||
kw['action'] = 'store_true'
|
||||
else:
|
||||
kw['metavar'] = metavar=option.__class__.__name__.upper()
|
||||
o = optparse.make_option('--%s' % to_cli(option.cli_name), **kw)
|
||||
if option.cli_short_name:
|
||||
o = optparse.make_option('-%s' % option.cli_short_name, '--%s' % to_cli(option.cli_name), **kw)
|
||||
else:
|
||||
o = optparse.make_option('--%s' % to_cli(option.cli_name), **kw)
|
||||
parser.add_option(o)
|
||||
return parser
|
||||
|
||||
|
@ -221,6 +221,7 @@ class Param(ReadOnly):
|
||||
|
||||
kwargs = (
|
||||
('cli_name', str, None),
|
||||
('cli_short_name', str, None),
|
||||
('label', callable, None),
|
||||
('doc', str, ''),
|
||||
('required', bool, True),
|
||||
@ -260,6 +261,13 @@ class Param(ReadOnly):
|
||||
self.name = check_name(name)
|
||||
self.nice = '%s(%r)' % (self.__class__.__name__, self.param_spec)
|
||||
|
||||
if 'cli_short_name' in kw:
|
||||
if len(kw['cli_short_name']) != 1:
|
||||
raise TypeError(
|
||||
'%s: cli_short_name can only be a single character: %s'
|
||||
% (self.nice, kw['cli_short_name'])
|
||||
)
|
||||
|
||||
# Add 'default' to self.kwargs and makes sure no unknown kw were given:
|
||||
assert type(self.type) is type
|
||||
if kw.get('multivalue', True):
|
||||
|
Loading…
Reference in New Issue
Block a user