diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-22 19:40:02 -0700 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-02-03 15:29:02 -0500 |
commit | e537dc89cbffee011cb985f5d6fd430dae3af000 (patch) | |
tree | 04fe8256da212aa079d8d9d4791f9afcd8d7827f | |
parent | 230712a88a99806909cbe4f4971bea7cc7740132 (diff) | |
download | freeipa-e537dc89cbffee011cb985f5d6fd430dae3af000.tar.gz freeipa-e537dc89cbffee011cb985f5d6fd430dae3af000.tar.xz freeipa-e537dc89cbffee011cb985f5d6fd430dae3af000.zip |
Fixed a few problems in the CLI interactive prompting (wont prompt for Flag now)
-rw-r--r-- | ipalib/cli.py | 16 | ||||
-rw-r--r-- | ipalib/parameters.py | 7 |
2 files changed, 12 insertions, 11 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 0afe09c46..26828e5d1 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -702,17 +702,14 @@ class CLI(object): result = cmd(**kw) if callable(cmd.output_for_cli): for param in cmd.params(): - if isinstance(param, Password): - try: - del kw[param.name] - except KeyError: - pass + if param.password and param.name in kw: + 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 not isinstance(param, Password): + if not param.password: continue if kw.get(param.name, False) is True or param.name in cmd.args: kw[param.name] = self.textui.prompt_password( @@ -733,12 +730,11 @@ class CLI(object): optional. """ for param in cmd.params(): - if isinstance(param, Password): + if param.password or param.autofill: continue elif param.name not in kw: if not param.required and not self.options.prompt_all: continue - print 'prompting for %r' % param.name default = param.get_default(**kw) error = None while True: @@ -803,7 +799,7 @@ class CLI(object): dest=option.name, help=option.doc, ) - if 'password' in option.flags: + if option.password: kw['action'] = 'store_true' elif option.type is bool: if option.default is True: @@ -822,7 +818,7 @@ 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: + if arg.password: continue name = to_cli(arg.cli_name).upper() if arg.multivalue: diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 0cf6a1f75..6ce0ad80a 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -243,6 +243,11 @@ class Param(ReadOnly): self.param_spec = name self.__kw = dict(kw) + if isinstance(self, Password): + self.password = True + else: + self.password = False + # Merge in kw from parse_param_spec(): if not ('required' in kw or 'multivalue' in kw): (name, kw_from_spec) = parse_param_spec(name) @@ -354,7 +359,7 @@ class Param(ReadOnly): return value def safe_value(self, value): - if isinstance(self, Password) and value is not None: + if self.password and value is not None: return u'********' return value |