modcli/output/
hooks.rs

1use crate::config::CliConfig;
2use std::sync::OnceLock;
3
4static CONFIG: OnceLock<CliConfig> = OnceLock::new();
5
6fn get_theme() -> String {
7    CONFIG.get_or_init(|| CliConfig::load("examples/config.json"))
8          .theme.clone().unwrap_or_else(|| "default".into())
9}
10
11fn styled(label: &str, message: &str, color: &str) {
12    match get_theme().as_str() {
13        "monochrome" => println!("[{}] {}", label, message),
14        _ => println!("\x1b[{}m[{}]\x1b[0m {}", color, label, message),
15    }
16}
17
18pub fn print_info(msg: &str) {
19    styled("INFO", msg, "36") // Cyan
20}
21
22pub fn print_warn(msg: &str) {
23    styled("WARN", msg, "33") // Yellow
24}
25
26pub fn print_error(msg: &str) {
27    styled("ERROR", msg, "31") // Red
28}
29
30pub fn print_success(msg: &str) {
31    styled("SUCCESS", msg, "32") // Green
32}
33
34pub fn print_status(msg: &str) {
35    styled("...", msg, "34") // Blue
36}