use std::fmt::Display;
use colored::Colorize;
use comfy_table::{presets::UTF8_FULL, ContentArrangement, Table};
pub fn info(msg: impl Display) {
println!("{}", msg);
}
pub fn success(msg: impl Display) {
println!("{}", format!("{msg}").green());
}
pub fn warn(msg: impl Display) {
eprintln!("{}", format!("{msg}").yellow());
}
pub fn error(msg: impl Display) {
eprintln!("{}", format!("{msg}").red());
}
pub fn make_table() -> Table {
let mut table = Table::new();
table
.load_preset(UTF8_FULL)
.set_content_arrangement(ContentArrangement::Dynamic);
table
}
pub fn print_json<T: serde::Serialize>(value: &T) -> Result<(), serde_json::Error> {
let s = serde_json::to_string_pretty(value)?;
println!("{s}");
Ok(())
}
pub fn status_label(ok: bool) -> String {
if ok {
"OK".green().to_string()
} else {
"FAIL".red().to_string()
}
}