use colored::Colorize;
use serde_json::Value;
#[allow(dead_code)]
pub struct OutputConfig {
pub json: bool,
pub quiet: bool,
pub no_color: bool,
}
impl OutputConfig {
pub fn print_header(&self, palace: &str, context: &str) {
if self.json || self.quiet {
return;
}
let header = format!("● {palace} / {context}");
println!("{}", header.bold());
println!("{}", "─".repeat(60).dimmed());
}
pub fn print_footer(&self, count: usize, layer: &str, ms: u64) {
if self.json || self.quiet {
return;
}
println!("{}", "─".repeat(60).dimmed());
println!(
"{}",
format!("{count} results · {layer} · {ms} ms").dimmed()
);
}
#[allow(dead_code)]
pub fn print_json(&self, value: &Value) {
match serde_json::to_string_pretty(value) {
Ok(s) => println!("{s}"),
Err(e) => eprintln!("error serializing JSON: {e}"),
}
}
pub fn print_error(&self, msg: &str) {
eprintln!("{} {msg}", "error:".red().bold());
}
pub fn print_success(&self, msg: &str) {
if !self.quiet {
println!("{} {msg}", "✓".green());
}
}
}