Files
eveAI/scripts/git/core/output.py
2025-12-11 09:27:21 +01:00

62 lines
1.4 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
import sys
class _Colors:
RESET = "\033[0m"
BOLD = "\033[1m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
def _print(message: str, *, prefix: str = "", color: str | None = None, stream=None) -> None:
if stream is None:
stream = sys.stdout
text = f"{prefix} {message}" if prefix else message
if color:
text = f"{color}{text}{_Colors.RESET}"
print(text, file=stream)
def info(message: str) -> None:
_print(message, prefix="", color=_Colors.BLUE)
def success(message: str) -> None:
_print(message, prefix="", color=_Colors.GREEN)
def warning(message: str) -> None:
_print(message, prefix="⚠️", color=_Colors.YELLOW, stream=sys.stderr)
def error(message: str) -> None:
_print(message, prefix="", color=_Colors.RED, stream=sys.stderr)
def heading(message: str) -> None:
_print(message, prefix="", color=_Colors.BOLD)
def plain(message: str) -> None:
_print(message)
class Notifier:
"""Abstractielaag voor toekomstige auditieve output.
Voor nu enkel console-notificaties; later kan dit uitgebreid
worden met TTS, systeemmeldingen, ...
"""
@staticmethod
def notify_event(event: str, detail: str | None = None) -> None: # pragma: no cover - placeholder
if detail:
info(f"[{event}] {detail}")
else:
info(f"[{event}]")