Michael Pasternak has uploaded a new change for review.

Change subject: cli: List/Show suggests parent+child as single param #950398
......................................................................

cli: List/Show suggests parent+child as single param #950398

Change-Id: Ice679b53fdbb2495721b224784f019405244e861
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=950398
Signed-off-by: Michael Pasternak <mpast...@redhat.com>
---
M src/ovirtcli/shell/engineshell.py
M src/ovirtcli/utils/methodhelper.py
2 files changed, 38 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/42/14142/1

diff --git a/src/ovirtcli/shell/engineshell.py 
b/src/ovirtcli/shell/engineshell.py
index a277c99..4b16d7e 100644
--- a/src/ovirtcli/shell/engineshell.py
+++ b/src/ovirtcli/shell/engineshell.py
@@ -33,15 +33,16 @@
 from ovirtcli.shell.consolecmdshell import ConsoleCmdShell
 from ovirtcli.shell.pingcmdshell import PingCmdShell
 from ovirtcli.shell.statuscmdshell import StatusCmdShell
-from ovirtcli.settings import OvirtCliSettings
 from ovirtcli.shell.clearcmdshell import ClearCmdShell
-
-from cli.command.help import HelpCommand
-from ovirtcli.prompt import PromptMode
 from ovirtcli.shell.filecmdshell import FileCmdShell
 from ovirtcli.shell.historycmdshell import HistoryCmdShell
-from cli.messages import Messages
 from ovirtcli.shell.infocmdshell import InfoCmdShell
+
+from ovirtcli.settings import OvirtCliSettings
+from ovirtcli.prompt import PromptMode
+
+from cli.command.help import HelpCommand
+from cli.messages import Messages
 
 class EngineShell(cmd.Cmd, ConnectCmdShell, ActionCmdShell, \
                   ShowCmdShell, ListCmdShell, UpdateCmdShell, \
@@ -166,7 +167,7 @@
 
     def normalize(self, line):
         normalized = line.lstrip()
-        rg = re.compile('((?:[a-z][a-z]+))( 
)(-)(-)(help)',re.IGNORECASE|re.DOTALL)
+        rg = re.compile('((?:[a-z][a-z]+))( )(-)(-)(help)', re.IGNORECASE | 
re.DOTALL)
         m = rg.search(normalized)
         if m:
             normalized = 'help ' + m.group(1)
@@ -176,6 +177,13 @@
         ret = cmd.Cmd.parseline(self, line)
         return ret
 
+    def completenames(self, text, *ignored):
+        dotext = 'do_' + text
+        res = [a[3:] for a in self.get_names() if a.startswith(dotext)]
+        if res and len(res) == 1:
+            res[0] = res[0] + ' '
+        return res
+
     def complete(self, text, state):
         content = []
         line = readline.get_line_buffer().lstrip()
diff --git a/src/ovirtcli/utils/methodhelper.py 
b/src/ovirtcli/utils/methodhelper.py
index 8ad9bc4..c494aa7 100644
--- a/src/ovirtcli/utils/methodhelper.py
+++ b/src/ovirtcli/utils/methodhelper.py
@@ -57,8 +57,11 @@
         if not groupOptions:
             if args:
                 if len(args) == 3:
-                    cand = expender(args[1], module, method) if 
expendNestedTypes\
-                                                             else args[1]
+                    if expendNestedTypes:
+                        cand = expender(args[1], module, method, [])
+                    else:
+                        cand = args[1]
+
                     cand = ", ".join(cand) if type(cand) == list else cand
 
                     if not holder.has_key(args[2]):
@@ -82,8 +85,10 @@
         else:
             if args:
                 if len(args) == 3:
-                    cand = expender(args[1], module, method) if 
expendNestedTypes\
-                                                             else args[1]
+                    if expendNestedTypes:
+                        cand = expender(args[1], module, method, [])
+                    else:
+                        cand = args[1]
                     cand = cand if type(cand) == list else [cand]
 
                     if not holder.has_key(args[2]):
@@ -115,12 +120,24 @@
                 holder[k] = ", ".join(sorted(new_val))
 
     @staticmethod
-    def __expend_nested_type(type_name, module, method):
+    def __expend_nested_type(type_name, module, method, expended_types):
+        """Recursive method's args types resolution"""
+        getMethodArgs = MethodHelper.getMethodArgs
+        expend_nested_type = MethodHelper.__expend_nested_type
+
         from ovirtcli.utils.typehelper import TypeHelper
         typ = TypeHelper.getDecoratorType(type_name)
+
         if typ:
-            return MethodHelper.getMethodArgs(module, typ, method, 
drop_self=True)
-        return type_name
+            expended_types_tmp = getMethodArgs(module, typ, method, 
drop_self=True)
+            if len(expended_types_tmp) > 1:
+                for item in expended_types_tmp:
+                    expend_nested_type(item, module, method, expended_types)
+            elif len(expended_types_tmp) > 0:
+                expended_types.append(expended_types_tmp[0])
+        else:
+            expended_types.append(type_name)
+        return expended_types
 
     @staticmethod
     def get_documented_arguments(method_ref, as_params_collection=False, 
spilt_or=False):


--
To view, visit http://gerrit.ovirt.org/14142
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice679b53fdbb2495721b224784f019405244e861
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: cli_3.2
Gerrit-Owner: Michael Pasternak <mpast...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to