-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconsole.py
More file actions
61 lines (41 loc) · 1.07 KB
/
console.py
File metadata and controls
61 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
This module provides functions for displaying outputs related to commitlint.
NOTE: If any future changes are made to the output implementation,
they will be done from here.
"""
import sys
from .config import config
GREEN = "\033[92m"
RED = "\033[91m"
RESET = "\033[0m"
def green(text: str) -> str:
return f"{GREEN}{text}{RESET}"
def red(text: str) -> str:
return f"{RED}{text}{RESET}"
def success(message: str) -> None:
"""
Print a success message.
Args:
message (str): The success message to print.
"""
if config.quiet:
return
sys.stdout.write(f"{green(message)}\n")
def error(message: str) -> None:
"""
Print an error message.
Args:
message (str): The error message to print.
"""
if config.quiet:
return
sys.stderr.write(f"{red(message)}\n")
def verbose(message: str) -> None:
"""
Print a verbose message if in verbose mode.
Args:
message (str): The verbose message to print.
"""
if not config.verbose:
return
sys.stdout.write(f"{message}\n")