use console::{Emoji, Style};
fn out() -> Style {
Style::new()
}
fn err() -> Style {
Style::new().for_stderr()
}
pub fn bold(text: &str) -> String {
out().bold().apply_to(text).to_string()
}
pub fn dim(text: &str) -> String {
out().dim().apply_to(text).to_string()
}
pub fn header(text: &str) -> String {
out().cyan().bold().apply_to(text).to_string()
}
pub fn green(text: &str) -> String {
out().green().apply_to(text).to_string()
}
pub fn green_bold(text: &str) -> String {
out().green().bold().apply_to(text).to_string()
}
pub fn red(text: &str) -> String {
out().red().apply_to(text).to_string()
}
pub fn red_bold(text: &str) -> String {
out().red().bold().apply_to(text).to_string()
}
pub fn yellow(text: &str) -> String {
out().yellow().apply_to(text).to_string()
}
pub fn yellow_bold(text: &str) -> String {
out().yellow().bold().apply_to(text).to_string()
}
pub fn cyan(text: &str) -> String {
out().cyan().apply_to(text).to_string()
}
pub fn magenta(text: &str) -> String {
out().magenta().apply_to(text).to_string()
}
pub fn white_bold(text: &str) -> String {
out().white().bold().apply_to(text).to_string()
}
pub fn err_red_bold(text: &str) -> String {
err().red().bold().apply_to(text).to_string()
}
pub fn err_dim(text: &str) -> String {
err().dim().apply_to(text).to_string()
}
pub fn err_cyan_bold(text: &str) -> String {
err().cyan().bold().apply_to(text).to_string()
}
pub fn err_yellow(text: &str) -> String {
err().yellow().apply_to(text).to_string()
}
pub fn effect(effect: &str) -> String {
match effect.to_lowercase().as_str() {
"allow" => green(effect),
"deny" => red(effect),
"ask" => yellow(effect),
_ => effect.to_string(),
}
}
pub fn effect_stderr(effect: &str) -> String {
match effect.to_lowercase().as_str() {
"allow" => err().green().apply_to(effect).to_string(),
"deny" => err().red().apply_to(effect).to_string(),
"ask" => err().yellow().apply_to(effect).to_string(),
_ => effect.to_string(),
}
}
static LIGHTNING: Emoji<'_, '_> = Emoji("⚡ ", "! ");
pub fn banner() -> String {
let s = out();
let box_style = s.clone().cyan();
let bolt = s.clone().yellow().bold().apply_to(LIGHTNING);
let title = s.clone().white().bold().apply_to("clash");
let tagline = s.dim().apply_to("· command-line agent safety harness");
let top = box_style.apply_to(" ┌───┐");
let left = box_style.apply_to(" │");
let right = box_style.apply_to("│");
let bot = box_style.apply_to(" └───┘");
format!("{top}\n{left}{bolt}{right} {title} {tagline}\n{bot}")
}
static SHIELD: Emoji<'_, '_> = Emoji("⛨", "*");
pub fn shield() -> String {
cyan(&SHIELD.to_string())
}