mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 16:31:08 -06:00
Set defaults even for optional arguments.
This commit is contained in:
parent
039ee0fd56
commit
3583735c60
@ -687,6 +687,7 @@ class CLI(object):
|
||||
if self.options.interactive:
|
||||
self.prompt_interactively(cmd, kw)
|
||||
self.prompt_for_passwords(cmd, kw)
|
||||
self.set_defaults(cmd, kw)
|
||||
result = cmd(**kw)
|
||||
if callable(cmd.output_for_cli):
|
||||
for param in cmd.params():
|
||||
@ -698,6 +699,13 @@ class CLI(object):
|
||||
(args, options) = cmd.params_2_args_options(kw)
|
||||
cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
|
||||
|
||||
def set_defaults(self, cmd, kw):
|
||||
for param in cmd.params():
|
||||
if not kw.get(param.name):
|
||||
value = param.get_default(**kw)
|
||||
if value:
|
||||
kw[param.name] = value
|
||||
|
||||
def prompt_for_passwords(self, cmd, kw):
|
||||
for param in cmd.params():
|
||||
if 'password' not in param.flags:
|
||||
|
Loading…
Reference in New Issue
Block a user