Skip to main content

hh_cli/agent/
color.rs

1use ratatui::style::Color;
2
3pub fn parse_color(s: &str) -> Option<Color> {
4    match s.to_lowercase().as_str() {
5        "black" => Some(Color::Black),
6        "red" => Some(Color::Red),
7        "green" => Some(Color::Green),
8        "yellow" => Some(Color::Yellow),
9        "blue" => Some(Color::Blue),
10        "magenta" => Some(Color::Magenta),
11        "cyan" => Some(Color::Cyan),
12        "white" => Some(Color::White),
13        "lightblack" | "gray" | "grey" => Some(Color::DarkGray),
14        "lightred" => Some(Color::LightRed),
15        "lightgreen" => Some(Color::LightGreen),
16        "lightyellow" => Some(Color::LightYellow),
17        "lightblue" => Some(Color::LightBlue),
18        "lightmagenta" | "lightpink" | "pink" => Some(Color::LightMagenta),
19        "lightcyan" => Some(Color::LightCyan),
20        "lightwhite" => Some(Color::White),
21        // Try to parse as RGB hex
22        hex => {
23            let hex = hex.trim_start_matches('#');
24            if hex.len() == 6
25                && let (Ok(r), Ok(g), Ok(b)) = (
26                    u8::from_str_radix(&hex[0..2], 16),
27                    u8::from_str_radix(&hex[2..4], 16),
28                    u8::from_str_radix(&hex[4..6], 16),
29                )
30            {
31                return Some(Color::Rgb(r, g, b));
32            }
33            None
34        }
35    }
36}
37
38pub fn default_agent_color() -> Color {
39    Color::White
40}