diff --git a/awscli/autoprompt/core.py b/awscli/autoprompt/core.py index 3b0bb900e47f..b7393f960ce1 100644 --- a/awscli/autoprompt/core.py +++ b/awscli/autoprompt/core.py @@ -87,9 +87,10 @@ class AutoPrompter: def __init__(self, completion_source, driver, prompter=None): self._completion_source = completion_source self._driver = driver + self._session = driver.session if prompter is None: prompter = PromptToolkitPrompter(self._completion_source, - self._driver) + self._driver,self._session) self._prompter = prompter def prompt_for_values(self, original_args): diff --git a/awscli/autoprompt/prompttoolkit.py b/awscli/autoprompt/prompttoolkit.py index 810cfd74b5ed..ee7ad206e3d9 100644 --- a/awscli/autoprompt/prompttoolkit.py +++ b/awscli/autoprompt/prompttoolkit.py @@ -59,7 +59,7 @@ class PromptToolkitPrompter: """ - def __init__(self, completion_source, driver, completer=None, + def __init__(self, completion_source, driver, session, completer=None, factory=None, app=None, cli_parser=None, output=None, app_input=None): self._completion_source = completion_source @@ -80,14 +80,15 @@ def __init__(self, completion_source, driver, completer=None, self.input_buffer = None self.doc_buffer = None self.output_buffer = None - if app is None: - app = self.create_application() - self.app = app self._args = [] self._driver = driver self._docs_getter = DocsGetter(self._driver) self._output_getter = OutputGetter(self._driver) - + self._session=session + if app is None: + app = self.create_application() + self.app = app + def args(self, value): self._args = value @@ -109,8 +110,12 @@ def _create_containers(self): return input_buffer_container, doc_window, output_window def create_application(self): - _colorDepth = {"black_and_white": ColorDepth.MONOCHROME, "ansi_colors": ColorDepth.ANSI_COLORS_ONLY,"256_colors": ColorDepth.DEFAULT, "true_colors": ColorDepth.TRUE_COLOR} - + # There are four different levels of color depths available in python-prompt-toolkit, + # which can be used to configure different color schemes in aws cli. You can read more + # about it in the documentation linked below: + # https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/styling.html?highlight=classes#color-depths + cliColorPalette = {"black_and_white": ColorDepth.MONOCHROME, "ansi_colors": ColorDepth.ANSI_COLORS_ONLY,"256_colors": ColorDepth.DEFAULT, "true_colors": ColorDepth.TRUE_COLOR} + cliColorDepth = self._session.get_config_variable('color_palette') self._create_buffers() input_buffer_container, \ doc_window, output_window = self._create_containers() @@ -123,7 +128,7 @@ def create_application(self): kb = kb_manager.keybindings app = Application(layout=layout, key_bindings=kb, full_screen=False, output=self._output, erase_when_done=True, - input=self._input, color_depth=_colorDepth["true_colors"]) + input=self._input, color_depth=cliColorPalette[cliColorDepth]) self._set_app_defaults(app) return app