Skip to main content

chub_cli/
output.rs

1#![allow(dead_code)] // Functions here are used across multiple command phases.
2
3use owo_colors::OwoColorize;
4
5/// Print an info message to stderr.
6pub fn info(msg: &str) {
7    eprintln!("{}", msg);
8}
9
10/// Print a warning to stderr.
11pub fn warn(msg: &str) {
12    eprintln!("{}", format!("Warning: {}", msg).yellow());
13}
14
15/// Print an error to stderr (or JSON to stdout).
16pub fn error(msg: &str, json: bool) {
17    if json {
18        println!("{}", serde_json::json!({ "error": msg }));
19    } else {
20        eprintln!("{}", format!("Error: {}", msg).red());
21    }
22}
23
24/// Print success message to stdout.
25pub fn success(msg: &str) {
26    println!("{}", msg.green());
27}