use owo_colors::OwoColorize;
pub fn kagi_styles() -> clap::builder::styling::Styles {
use clap::builder::styling::{Color, RgbColor, Style, Styles};
Styles::styled()
.header(
Style::new()
.bold()
.fg_color(Some(Color::Rgb(RgbColor(188, 111, 35)))),
)
.usage(
Style::new()
.bold()
.fg_color(Some(Color::Rgb(RgbColor(45, 93, 145)))),
)
.literal(Style::new().fg_color(Some(Color::Rgb(RgbColor(72, 121, 78)))))
.placeholder(Style::new().fg_color(Some(Color::Rgb(RgbColor(164, 74, 61)))))
.error(
Style::new()
.bold()
.fg_color(Some(Color::Rgb(RgbColor(190, 55, 43)))),
)
.valid(Style::new().fg_color(Some(Color::Rgb(RgbColor(72, 121, 78)))))
.invalid(Style::new().fg_color(Some(Color::Rgb(RgbColor(190, 55, 43)))))
}
pub struct Palette {
tty: bool,
}
impl Palette {
pub fn new(tty: bool) -> Self {
Self { tty }
}
fn apply(&self, text: &str, rgb: (u8, u8, u8)) -> String {
if self.tty {
text.truecolor(rgb.0, rgb.1, rgb.2).bold().to_string()
} else {
text.to_string()
}
}
fn plain(&self, text: &str) -> String {
text.to_string()
}
pub fn prefix(&self) -> String {
self.apply("kagi:", (35, 82, 133))
}
pub fn success(&self, text: &str) -> String {
self.apply(text, (72, 121, 78))
}
pub fn info(&self, text: &str) -> String {
self.plain(text)
}
pub fn warning(&self, text: &str) -> String {
self.apply(text, (188, 111, 35))
}
pub fn error(&self, text: &str) -> String {
self.apply(text, (190, 55, 43))
}
pub fn accent(&self, text: &str) -> String {
self.apply(text, (35, 82, 133))
}
pub fn key(&self, text: &str) -> String {
self.apply(text, (164, 74, 61))
}
pub fn prompt(&self, text: &str) -> String {
self.apply(text, (176, 105, 31))
}
pub fn muted(&self, text: &str) -> String {
self.apply(text, (140, 140, 140))
}
pub fn commented(&self, text: &str) -> String {
self.apply(text, (150, 82, 86))
}
}