use std::fmt::Display;
use termion::{color, style};
const SEPARATOR: &str = "****************************************";
fn styled(fg: impl color::Color, text: impl Display) -> String {
format!(
"{}{}{}{}{}",
color::Fg(fg),
style::Italic,
style::Bold,
text,
style::Reset
)
}
pub fn error(text: impl Display) {
println!("{}", styled(color::Red, text));
}
pub fn success(text: impl Display) {
println!("{}", styled(color::Green, text));
}
pub fn warn(text: impl Display) {
println!("{}", styled(color::Yellow, text));
}
pub fn separator() {
println!("{}", styled(color::Black, SEPARATOR));
}
pub fn field(key: &str, value: impl Display) {
println!("{} {}", styled(color::Cyan, key), value);
}
pub fn error_field(key: &str, value: impl Display) {
println!("{} {}", styled(color::Red, key), value);
}
pub fn headers<'a>(entries: impl IntoIterator<Item = (&'a str, &'a str)>) {
println!("{}", styled(color::Cyan, "Header:"));
for (key, value) in entries {
println!(" [{key}]: {value}");
}
}