const DEFAULT_AGENT_THEME_COLOR: &str = "cyan_FOR_SUBAGENTS_ONLY";
pub fn to_ink_color(color: Option<&str>) -> String {
let Some(color) = color else {
return DEFAULT_AGENT_THEME_COLOR.to_string();
};
if let Some(theme_color) = agent_color_to_theme_color(color) {
return theme_color.to_string();
}
format!("ansi:{color}")
}
fn agent_color_to_theme_color(color: &str) -> Option<&'static str> {
match color {
"blue" => Some("blue"),
"green" => Some("green"),
"red" => Some("red"),
"yellow" => Some("yellow"),
"cyan" => Some("cyan"),
"magenta" => Some("magenta"),
"white" => Some("white"),
"gray" => Some("gray"),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_to_ink_color_none() {
assert_eq!(to_ink_color(None), DEFAULT_AGENT_THEME_COLOR);
}
#[test]
fn test_to_ink_color_known() {
assert_eq!(to_ink_color(Some("blue")), "blue");
}
#[test]
fn test_to_ink_color_unknown() {
assert_eq!(to_ink_color(Some("orange")), "ansi:orange");
}
}