fix: if NO_COLOR set ignore ansi.custom setting

This commit is contained in:
Daylin Morgan 2022-10-03 16:02:49 -05:00
parent 14b6dccbc9
commit 6dad870b23

View file

@ -65,6 +65,9 @@ class Ansi:
"""use custom color""" """use custom color"""
code, end = "\033[", "m" code, end = "\033[", "m"
if not sys.stdout.isatty() or os.getenv("NO_COLOR", False):
return ""
else:
if fg: if fg:
if isinstance(fg, int): if isinstance(fg, int):
code += f"38;5;{fg}" code += f"38;5;{fg}"
@ -112,5 +115,6 @@ class Ansi:
a = ansi = Ansi() a = ansi = Ansi()
cfg = Config( cfg = Config(
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""",int('$(WRAP)')) "$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""", int("$(WRAP)")
)
#% endblock %# #% endblock %#