summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-13 23:54:34 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-13 23:54:34 -0700
commit82d3de773b2504145cddbcf8a6e5d1abf58fcb12 (patch)
treed751344af91042ae61ab5860b60c816017ea3b02 /ipalib
parentf5594dd489317dc406d20f897fc720e0cf89c9d2 (diff)
downloadfreeipa-82d3de773b2504145cddbcf8a6e5d1abf58fcb12.tar.gz
freeipa-82d3de773b2504145cddbcf8a6e5d1abf58fcb12.tar.xz
freeipa-82d3de773b2504145cddbcf8a6e5d1abf58fcb12.zip
Added textui.prompt() method, which CLI.prompt_interactively() uses
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/cli.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 5659cfc0..3b365cdb 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -235,6 +235,16 @@ class textui(backend.Backend):
return singular % n
return plural % n
+ def prompt(self, label, default=None, get_values=None):
+ """
+ Prompt user for input.
+ """
+ if default is None:
+ prompt = '%s: ' % label
+ else:
+ prompt = '%s [%s]: ' % (label, default)
+ return raw_input(prompt)
+
class help(frontend.Application):
'''Display help on a command.'''
@@ -489,6 +499,7 @@ class CLI(object):
self.__d = dict(
(c.name.replace('_', '-'), c) for c in self.api.Command()
)
+ self.textui = self.api.Backend.textui
def load_plugins(self):
"""
@@ -584,15 +595,11 @@ class CLI(object):
if not (param.required or self.options.prompt_all):
continue
default = param.get_default(**kw)
- if default is None:
- prompt = '%s: ' % param.cli_name
- else:
- prompt = '%s [%s]: ' % (param.cli_name, default)
error = None
while True:
if error is not None:
print '>>> %s: %s' % (param.cli_name, error)
- raw = raw_input(prompt)
+ raw = self.textui.prompt(param.cli_name, default)
try:
value = param(raw, **kw)
if value is not None: