summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-02-22 07:25:03 -0500
committerMartin Kosek <mkosek@redhat.com>2013-02-26 18:19:16 +0100
commit8b8859ed7d457f88fbf479bcfe164a9fda8eb413 (patch)
tree07a42701121ac810a9176473648894959586da9a
parent68ffb4af2f9b1000492363c4979d049077ada893 (diff)
downloadfreeipa.git-8b8859ed7d457f88fbf479bcfe164a9fda8eb413.tar.gz
freeipa.git-8b8859ed7d457f88fbf479bcfe164a9fda8eb413.tar.xz
freeipa.git-8b8859ed7d457f88fbf479bcfe164a9fda8eb413.zip
cli: Do interactive prompting after a context is created
Some commands require a connection for interactive prompting. Prompt after the connection is created. Option parsing is still done before connecting so that help can be printed out without a Kerberos ticket. https://fedorahosted.org/freeipa/ticket/3453
-rw-r--r--ipalib/cli.py6
-rw-r--r--tests/test_cmdline/test_cli.py3
2 files changed, 5 insertions, 4 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index c3926c36..e379f073 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -1039,9 +1039,8 @@ class cli(backend.Executioner):
cmd = self.Command[name]
return cmd
- def argv_to_keyword_arguments(self, cmd, argv):
+ def process_keyword_arguments(self, cmd, kw):
"""Get the keyword arguments for a Command"""
- kw = self.parse(cmd, argv)
if self.env.interactive:
self.prompt_interactively(cmd, kw)
if self.env.interactive:
@@ -1061,10 +1060,11 @@ class cli(backend.Executioner):
if cmd is None:
return
name = cmd.name
- kw = self.argv_to_keyword_arguments(cmd, argv[1:])
+ kw = self.parse(cmd, argv[1:])
if not isinstance(cmd, frontend.Local):
self.create_context()
try:
+ kw = self.process_keyword_arguments(cmd, kw)
result = self.execute(name, **kw)
if callable(cmd.output_for_cli):
for param in cmd.params():
diff --git a/tests/test_cmdline/test_cli.py b/tests/test_cmdline/test_cli.py
index 388c54e2..75d1608e 100644
--- a/tests/test_cmdline/test_cli.py
+++ b/tests/test_cmdline/test_cli.py
@@ -18,7 +18,8 @@ class TestCLIParsing(object):
executioner = api.Backend.cli
cmd = executioner.get_command(argv)
- kw_got = executioner.argv_to_keyword_arguments(cmd, argv[1:])
+ kw_got = executioner.parse(cmd, argv[1:])
+ kw_got = executioner.process_keyword_arguments(cmd, kw_got)
util.assert_deepequal(expected_command_name, cmd.name, 'Command name')
util.assert_deepequal(kw_expected, kw_got)