Tidying color stuff

This commit is contained in:
Eric Froemling 2020-04-30 19:58:02 -07:00
parent 35edfbd375
commit e0b24e170f
2 changed files with 16 additions and 1 deletions

View File

@ -32,7 +32,11 @@ if TYPE_CHECKING:
@unique
class TerminalColor(Enum):
"""Color codes for printing to terminals."""
"""Color codes for printing to terminals.
Generally the Clr class should be used when incorporating color into
terminal output, as it handles non-color-supporting terminals/etc.
"""
# Styles
RESET = '\033[0m'

View File

@ -614,5 +614,16 @@ def filter_server_config() -> None:
batools.build.filter_server_config(sys.argv[2], sys.argv[3])
def printcolors() -> None:
"""Print all colors available in efro.terminals.TerminalColor."""
from efro.terminal import TerminalColor
for value in TerminalColor:
if value is TerminalColor.RESET:
continue
print(f'{value.name}: {value.value}'
f'The quick brown fox jumps over the lazy dog.'
f'{TerminalColor.RESET.value}')
if __name__ == '__main__':
snippets_main(globals())