mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-04 20:02:05 +00:00
37 lines
952 B
Python
37 lines
952 B
Python
"""Utility functions for SeedPass CLI color scheme."""
|
|
|
|
from termcolor import colored
|
|
|
|
|
|
# ANSI escape for 256-color orange (color code 208)
|
|
_ORANGE = "\033[38;5;208m"
|
|
_RESET = "\033[0m"
|
|
|
|
|
|
def _apply_orange(text: str) -> str:
|
|
"""Return text wrapped in ANSI codes for orange."""
|
|
return f"{_ORANGE}{text}{_RESET}"
|
|
|
|
|
|
# Mapping of semantic color categories to actual colors
|
|
_COLOR_MAP = {
|
|
"deterministic": "red",
|
|
"imported": "orange",
|
|
"index": "yellow",
|
|
"menu": "cyan",
|
|
"stats": "green",
|
|
"info": "white",
|
|
"warning": "yellow",
|
|
"error": "red",
|
|
"default": "white",
|
|
}
|
|
|
|
|
|
def color_text(text: str, category: str = "default") -> str:
|
|
"""Colorize ``text`` according to the given category."""
|
|
color = _COLOR_MAP.get(category, "white")
|
|
if color == "orange":
|
|
return _apply_orange(text)
|
|
attrs = ["bold"] if category in {"info", "warning", "error"} else []
|
|
return colored(text, color, attrs=attrs)
|