]> Witch of Git - ivy/blob - tools/fmt.py
[tools] Move ANSI color printing code into its own file
[ivy] / tools / fmt.py
1 import sys
2
3
4 IS_TTY = sys.stdout.isatty()
5
6
7 def red(x):
8 if not IS_TTY:
9 return x
10 return f"\033[31m{x}\033[0m"
11
12
13 def green(x):
14 if not IS_TTY:
15 return x
16 return f"\033[32m{x}\033[0m"
17
18
19 def yellow(x):
20 if not IS_TTY:
21 return x
22 return f"\033[33m{x}\033[0m"
23
24
25 def blue(x):
26 if not IS_TTY:
27 return x
28 return f"\033[34m{x}\033[0m"