use console::style;
use serde::Serialize;
#[derive(Debug)]
pub struct QuietExit(pub i32);
impl std::fmt::Display for QuietExit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "exit status {}", self.0)
}
}
impl std::error::Error for QuietExit {}
pub fn json<T: Serialize>(value: &T) -> anyhow::Result<()> {
println!("{}", serde_json::to_string_pretty(value)?);
Ok(())
}
pub fn heading(text: &str) {
println!("\n{}", style(text).bold().underlined());
}
pub fn success(text: &str) {
println!("{} {text}", style("✓").green().bold());
}
pub fn warn(text: &str) {
println!("{} {text}", style("!").yellow().bold());
}
pub fn progress(text: &str) {
eprintln!(" {}", style(text).dim());
}
pub fn note(text: &str) {
println!(" {}", style(text).dim());
}
pub fn item(name: &str, detail: &str) {
println!(" {} {}", style(name).cyan(), style(detail).dim());
}