17 lines
314 B
Python
17 lines
314 B
Python
import sys
|
|
|
|
ANSI = {
|
|
"green": "\033[32m",
|
|
"yellow": "\033[33m",
|
|
"red": "\033[31m",
|
|
"cyan": "\033[36m",
|
|
"bold": "\033[1m",
|
|
"reset": "\033[0m",
|
|
}
|
|
|
|
|
|
def _c(color: str, text: str) -> str:
|
|
if sys.stdout.isatty():
|
|
return f"{ANSI[color]}{text}{ANSI['reset']}"
|
|
return text
|