Skip to content

Commit

Permalink
Added NO_COLOR support
Browse files Browse the repository at this point in the history
  • Loading branch information
trag1c committed Sep 23, 2022
1 parent d71e360 commit c90912d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dahlia/dahlia.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
from enum import Enum
from os import system
from os import environ, system
from re import compile
from sys import platform
from typing import Any
Expand Down Expand Up @@ -91,6 +91,8 @@
24: "\033[48;2;{};{};{}m",
}

NO_COLOR = environ.get("NO_COLOR", "").casefold() in ("1", "true")


class Depth(Enum):
LOW = 3
Expand Down Expand Up @@ -162,6 +164,8 @@ def convert(self, string: str) -> str:
str
A formatted string with the appropriate formatting applied.
"""
if NO_COLOR:
return clean(string)
if not (string.endswith("&r") or self.no_reset):
string += "&r"
for code, bg, color in _find_codes(string):
Expand Down

0 comments on commit c90912d

Please sign in to comment.