From e8e83b566386e65a3efff87460a800bdacf3cb45 Mon Sep 17 00:00:00 2001 From: xiaxuantan Date: Thu, 26 Apr 2018 16:00:55 +0800 Subject: [PATCH 1/2] add support for multiline command --- awsshell/app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/awsshell/app.py b/awsshell/app.py index 84b5660..3b4cb5e 100644 --- a/awsshell/app.py +++ b/awsshell/app.py @@ -12,7 +12,7 @@ from prompt_toolkit.document import Document from prompt_toolkit.shortcuts import create_eventloop from prompt_toolkit.buffer import Buffer -from prompt_toolkit.filters import Always +from prompt_toolkit.filters import Always, Condition from prompt_toolkit.interface import CommandLineInterface, Application from prompt_toolkit.interface import AbortAction, AcceptAction from prompt_toolkit.auto_suggest import AutoSuggestFromHistory @@ -27,7 +27,6 @@ from awsshell.utils import build_config_file_path, temporary_file from awsshell import compat - LOG = logging.getLogger(__name__) EXIT_REQUESTED = object() @@ -344,14 +343,21 @@ def create_layout(self, display_completions_in_columns, toolbar): get_bottom_toolbar_tokens=toolbar.handler) def create_buffer(self, completer, history): - return Buffer( + + def is_buffer_multiline(): + return buffer.document.text.endswith('\\') + + buffer = Buffer( history=history, auto_suggest=AutoSuggestFromHistory(), enable_history_search=True, completer=completer, complete_while_typing=Always(), + is_multiline=Condition(is_buffer_multiline), accept_action=AcceptAction.RETURN_DOCUMENT) + return buffer + def create_key_manager(self): """Create the :class:`KeyManager`. @@ -365,6 +371,7 @@ def create_key_manager(self): options take effect within the current session. """ + def set_match_fuzzy(match_fuzzy): """Setter for fuzzy matching mode. From 35375965596a6f1ae848a7e914d25948c68cd65e Mon Sep 17 00:00:00 2001 From: xiaxuantan Date: Thu, 26 Apr 2018 16:43:37 +0800 Subject: [PATCH 2/2] make code compatible with all style conventions --- awsshell/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awsshell/app.py b/awsshell/app.py index 3b4cb5e..3ef73a7 100644 --- a/awsshell/app.py +++ b/awsshell/app.py @@ -27,6 +27,7 @@ from awsshell.utils import build_config_file_path, temporary_file from awsshell import compat + LOG = logging.getLogger(__name__) EXIT_REQUESTED = object() @@ -343,7 +344,6 @@ def create_layout(self, display_completions_in_columns, toolbar): get_bottom_toolbar_tokens=toolbar.handler) def create_buffer(self, completer, history): - def is_buffer_multiline(): return buffer.document.text.endswith('\\') @@ -371,7 +371,6 @@ def create_key_manager(self): options take effect within the current session. """ - def set_match_fuzzy(match_fuzzy): """Setter for fuzzy matching mode.