mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow to specifically customize console's color
This commit is contained in:
parent
3bb9f689e9
commit
ac1f05478e
3 changed files with 15 additions and 3 deletions
2
changelogs/fragments/console_color.yml
Normal file
2
changelogs/fragments/console_color.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- allow user to customize default ansible-console prompt/msg default color
|
|
@ -38,7 +38,6 @@ import sys
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.cli import CLI
|
from ansible.cli import CLI
|
||||||
from ansible.errors import AnsibleError
|
|
||||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||||
from ansible.module_utils._text import to_native, to_text
|
from ansible.module_utils._text import to_native, to_text
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
|
@ -62,6 +61,9 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
||||||
ARGUMENTS = {'host-pattern': 'A name of a group in the inventory, a shell-like glob '
|
ARGUMENTS = {'host-pattern': 'A name of a group in the inventory, a shell-like glob '
|
||||||
'selecting hosts in inventory or any combination of the two separated by commas.'}
|
'selecting hosts in inventory or any combination of the two separated by commas.'}
|
||||||
|
|
||||||
|
# use specific to console, but fallback to highlight for backwards compatibility
|
||||||
|
NORMAL_PROMPT = C.COLOR_CONSOLE_PROMPT or C.COLOR_HIGHLIGHT
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
|
|
||||||
super(ConsoleCLI, self).__init__(args)
|
super(ConsoleCLI, self).__init__(args)
|
||||||
|
@ -122,7 +124,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
||||||
color = C.COLOR_ERROR
|
color = C.COLOR_ERROR
|
||||||
else:
|
else:
|
||||||
prompt += "$ "
|
prompt += "$ "
|
||||||
color = C.COLOR_HIGHLIGHT
|
color = self.NORMAL_PROMPT
|
||||||
self.prompt = stringc(prompt, color)
|
self.prompt = stringc(prompt, color)
|
||||||
|
|
||||||
def list_modules(self):
|
def list_modules(self):
|
||||||
|
@ -361,7 +363,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
||||||
display.display(oc['short_description'])
|
display.display(oc['short_description'])
|
||||||
display.display('Parameters:')
|
display.display('Parameters:')
|
||||||
for opt in oc['options'].keys():
|
for opt in oc['options'].keys():
|
||||||
display.display(' ' + stringc(opt, C.COLOR_HIGHLIGHT) + ' ' + oc['options'][opt]['description'][0])
|
display.display(' ' + stringc(opt, self.NORMAL_PROMPT) + ' ' + oc['options'][opt]['description'][0])
|
||||||
else:
|
else:
|
||||||
display.error('No documentation found for %s.' % module_name)
|
display.error('No documentation found for %s.' % module_name)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -211,6 +211,14 @@ COLOR_CHANGED:
|
||||||
ini:
|
ini:
|
||||||
- {key: changed, section: colors}
|
- {key: changed, section: colors}
|
||||||
yaml: {key: display.colors.changed}
|
yaml: {key: display.colors.changed}
|
||||||
|
COLOR_CONSOLE_PROMPT:
|
||||||
|
name: "Color for ansible-console's prompt task status"
|
||||||
|
default: white
|
||||||
|
description: Defines the default color to use for ansible-console
|
||||||
|
env: [{name: ANSIBLE_COLOR_CONSOLE_PROMPT}]
|
||||||
|
ini:
|
||||||
|
- {key: console_prompt, section: colors}
|
||||||
|
version_added: "2.7"
|
||||||
COLOR_DEBUG:
|
COLOR_DEBUG:
|
||||||
name: Color for debug statements
|
name: Color for debug statements
|
||||||
default: dark gray
|
default: dark gray
|
||||||
|
|
Loading…
Reference in a new issue