Juan Hernandez has uploaded a new change for review. Change subject: Revert "cli: mismatch between restore snapshot syntax and auto completion #1027298" ......................................................................
Revert "cli: mismatch between restore snapshot syntax and auto completion #1027298" This reverts commit 870b0c as it introduces a regression: moving the options to the end of the command moves them past the redirections and pipes, and this causes a syntax error. This is the bug that the change intended to fix: https://bugzilla.redhat.com/1047513 A later patch introduces changes in the syntax of commands allowing mixing arguments and options. That fixes the above bug as well as the regression. Change-Id: I7b85120e6479c4be3dd2357ef8731cd1388b8885 Bug-Url: https://bugzilla.redhat.com/1047513 Signed-off-by: Juan Hernandez <[email protected]> --- M src/ovirtcli/infrastructure/historymanager.py M src/ovirtcli/shell/actioncmdshell.py M src/ovirtcli/shell/engineshell.py 3 files changed, 4 insertions(+), 86 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/65/22865/1 diff --git a/src/ovirtcli/infrastructure/historymanager.py b/src/ovirtcli/infrastructure/historymanager.py index 7edb515..fa2336a 100644 --- a/src/ovirtcli/infrastructure/historymanager.py +++ b/src/ovirtcli/infrastructure/historymanager.py @@ -86,10 +86,6 @@ if self.length() > 0: readline.remove_history_item(entry) - def add(self, entry): - if self.enabled: - readline.add_history(entry) - def __unregister_dump_callback(self): for item in atexit._exithandlers: if hasattr(item[0], 'func_name') and \ diff --git a/src/ovirtcli/shell/actioncmdshell.py b/src/ovirtcli/shell/actioncmdshell.py index ed2dfc6..93e03b5 100644 --- a/src/ovirtcli/shell/actioncmdshell.py +++ b/src/ovirtcli/shell/actioncmdshell.py @@ -20,7 +20,7 @@ from ovirtcli.utils.autocompletionhelper import AutoCompletionHelper from ovirtsdk.infrastructure import brokers from ovirtcli.utils.methodhelper import MethodHelper -import sys + class ActionCmdShell(CmdShell): NAME = 'action' @@ -31,82 +31,7 @@ self.identifier_template = '--%s-identifier' def do_action(self, args): - nargs = self.__reformat_args(args) - return self.context.execute_string(ActionCmdShell.NAME + ' ' + nargs + '\n') - - def __update_history(self, nargs): - """ - replaces history entry with reformatted content - - @param nargs: new entry to add - """ - if self.context.history.length() >= 1: - self.context.history.remove(self.context.history.length() - 1) - self.context.history.add(ActionCmdShell.NAME + " " + nargs) - - def __reformat_args(self, args): - """ - 1. Replaces current line with new content formated according - to command syntax, use-case: - - * action could not be determinated unless object parent/s is/are specified - - from: - action object xxx --parent-identifier yyy action-name - to: - action object xxx action-name --parent-identifier yyy - - 2. replaces history entry with reformatted content - - @param args: original args - @return: reformatted args - """ - cursor_up = '\x1b[1A' - erase_line = '\x1b[K' - sys.stdout.write(cursor_up + erase_line) - nargs = self.__reformat_command(args) - self.print_line( - ((self.prompt.replace("\001", "")).replace("\002", "")) # remove escape sequences/behave like a string - + - ActionCmdShell.NAME - + - " " - + - nargs, - no_prompt=True - ) - self.__update_history(nargs) - return nargs - - def __reformat_command(self, s): - """ - Reformats command according to the default command syntax, - use-case: - - * action name could not be determinated unless object parents is specified - - from: - action object xxx --parent-identifier yyy action-name - to: - action object xxx action-name --parent-identifier yyy - - """ - line = '' - arguments = '' - tokens = s.split(' ') - tokens_len = len(tokens) - i = 0 - while i < tokens_len: - if tokens[i].startswith('--'): - arguments = arguments + ' ' + tokens[i].strip() - i = i + 1 - if i < tokens_len and not tokens[i].startswith('--'): - arguments = arguments + ' ' + tokens[i].strip() - i = i + 1 - else: - line = line + ' ' + tokens[i].strip() - i = i + 1 - return line.strip() + ' ' + arguments.strip() + return self.context.execute_string(ActionCmdShell.NAME + ' ' + args + '\n') def __add_resource_specific_options(self, obj, specific_options, line, key=None): obj_type = TypeHelper.getDecoratorType(TypeHelper.to_singular(obj)) diff --git a/src/ovirtcli/shell/engineshell.py b/src/ovirtcli/shell/engineshell.py index 30f8055..03876c7 100644 --- a/src/ovirtcli/shell/engineshell.py +++ b/src/ovirtcli/shell/engineshell.py @@ -120,11 +120,8 @@ self._error(str(e)) return self.cmdloop(intro, clear=False) - def print_line(self, line, no_prompt=False): - if no_prompt: - print line - else: - print self.prompt + line + def print_line(self, line): + print self.prompt + line def emptyline(self, no_prompt=False): if no_prompt: -- To view, visit http://gerrit.ovirt.org/22865 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7b85120e6479c4be3dd2357ef8731cd1388b8885 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
