Skip to content
Snippets Groups Projects

add color to NOK, OK, ???, and error prints

Merged Anjan Momi requested to merge anjandev/mrhlpr:anjan/color-print into master
All threads resolved!
+ 10
8
@@ -3,7 +3,7 @@
"""Pretty outputs and such."""
import argparse
from enum import StrEnum, unique
from enum import Enum, unique
import logging
import sys
from typing import Any
@@ -21,16 +21,15 @@ from . import version
@unique
class ColorCode(StrEnum):
OKGREEN = '\033[1;32m'
ORANGE = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
class ColorCode(str, Enum):
OKGREEN = "\033[1;32m"
ORANGE = "\033[93m"
RED = "\033[91m"
ENDC = "\033[0m"
@unique
class ActionType(StrEnum):
class ActionType(str, Enum):
OK = "[OK ]"
NOK = "[NOK]"
UNKNOWN = "[???]"
@@ -47,12 +46,15 @@ class ActionType(StrEnum):
case _:
raise ValueError(f"No defined color for action {self}")
def print_action(msg_type: ActionType, message: str) -> None:
print(f"{msg_type.color}{msg_type} {message}{ColorCode.ENDC}")
def print_error(message: str) -> None:
print(f"{ColorCode.RED}{message}{ColorCode.ENDC}")
def print_status(mr_id: int, no_cache: bool = False) -> None:
"""Print the merge request status. Most info is only visible, when the
branch is checked out locally. Always display a checklist of things to
Loading