use owo_colors::OwoColorize;
use std::io::IsTerminal;
pub fn init_color(force_no_color: bool) {
let no_color = force_no_color
|| std::env::var_os("NO_COLOR").is_some()
|| !std::io::stdout().is_terminal()
|| !std::io::stderr().is_terminal();
if no_color {
owo_colors::set_override(false);
}
}
pub fn info(msg: impl AsRef<str>) {
eprintln!("{} {}", "[信息]".green().bold(), msg.as_ref());
}
pub fn ok(msg: impl AsRef<str>) {
eprintln!("{} {}", "[成功]".green().bold(), msg.as_ref());
}
pub fn warn(msg: impl AsRef<str>) {
eprintln!("{} {}", "[警告]".yellow().bold(), msg.as_ref());
}
pub fn err(msg: impl AsRef<str>) {
eprintln!("{} {}", "[错误]".red().bold(), msg.as_ref());
}
pub fn hint(msg: impl AsRef<str>) {
eprintln!("{} {}", "[提示]".cyan().bold(), msg.as_ref());
}