summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-18 13:43:43 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-18 13:43:43 -0700
commit4afee15d4b523a641552bee9993882bb1ae6e2cc (patch)
tree907887251011a9979c65b7c7ab5b0e7c2e2fddef /ipalib/cli.py
parent0a60a6bcc4c8eaa7d42dc25fa6fc69d837e3e816 (diff)
downloadfreeipa-4afee15d4b523a641552bee9993882bb1ae6e2cc.tar.gz
freeipa-4afee15d4b523a641552bee9993882bb1ae6e2cc.tar.xz
freeipa-4afee15d4b523a641552bee9993882bb1ae6e2cc.zip
Calling 'passwd' command now prompts for password using textui.prompt_password()
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 7cbf6e4bb..b3aa10994 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -658,12 +658,28 @@ class CLI(object):
def run_cmd(self, cmd):
kw = self.parse(cmd)
if self.options.interactive:
- kw = self.prompt_interactively(cmd, kw)
+ self.prompt_interactively(cmd, kw)
+ self.prompt_for_passwords(cmd, kw)
result = cmd(**kw)
if callable(cmd.output_for_cli):
+ for param in cmd.params():
+ if param.ispassword():
+ del kw[param.name]
(args, options) = cmd.params_2_args_options(kw)
cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
+ def prompt_for_passwords(self, cmd, kw):
+ for param in cmd.params():
+ if 'password' not in param.flags:
+ continue
+ if kw.get(param.name, False) is True or param.name in cmd.args:
+ kw[param.name] = self.textui.prompt_password(
+ param.cli_name
+ )
+ else:
+ kw.pop(param.name, None)
+ return kw
+
def prompt_interactively(self, cmd, kw):
"""
Interactively prompt for missing or invalid values.
@@ -676,12 +692,7 @@ class CLI(object):
"""
for param in cmd.params():
if 'password' in param.flags:
- if kw.get(param.name, False) is True:
- kw[param.name] = self.textui.prompt_password(
- param.cli_name
- )
- else:
- kw.pop(param.name, None)
+ continue
elif param.name not in kw:
if not (param.required or self.options.prompt_all):
continue
@@ -760,6 +771,8 @@ class CLI(object):
def get_usage_iter(self, cmd):
yield 'Usage: %%prog [global-options] %s' % to_cli(cmd.name)
for arg in cmd.args():
+ if 'password' in arg.flags:
+ continue
name = to_cli(arg.cli_name).upper()
if arg.multivalue:
name = '%s...' % name