summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-12-10 13:49:59 -0500
committerRob Crittenden <rcritten@redhat.com>2008-12-10 14:15:20 -0500
commit3583735c60515d604b02ddb0c62e3da9c47807cf (patch)
treeecc6b81c61e900eb13b8fca7d31c2f164f014b6d
parent039ee0fd56bbca60a79c99cdd489a1590f6f2b78 (diff)
downloadfreeipa-3583735c60515d604b02ddb0c62e3da9c47807cf.tar.gz
freeipa-3583735c60515d604b02ddb0c62e3da9c47807cf.tar.xz
freeipa-3583735c60515d604b02ddb0c62e3da9c47807cf.zip
Set defaults even for optional arguments.
-rw-r--r--ipalib/cli.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index af3eb6e35..ca3364aef 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -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: