From fc8ac693726ec33b5c0924f9b8ff5d663705a5a3 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 5 Dec 2008 15:31:18 -0500 Subject: Port plugins to use the new output_for_cli() argument list Fix some errors uncovered by the nosetests --- ipalib/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index 37fdad44..af3eb6e3 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -691,7 +691,10 @@ class CLI(object): if callable(cmd.output_for_cli): for param in cmd.params(): if param.ispassword(): - del kw[param.name] + try: + del kw[param.name] + except KeyError: + pass (args, options) = cmd.params_2_args_options(kw) cmd.output_for_cli(self.api.Backend.textui, result, *args, **options) -- cgit From 3583735c60515d604b02ddb0c62e3da9c47807cf Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 10 Dec 2008 13:49:59 -0500 Subject: Set defaults even for optional arguments. --- ipalib/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index af3eb6e3..ca3364ae 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: -- cgit