Set defaults even for optional arguments.

This commit is contained in:
Rob Crittenden 2008-12-10 13:49:59 -05:00
parent 039ee0fd56
commit 3583735c60

View File

@ -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: