use colored::Colorize;
use std::env;
pub fn init_colors() {
colored::control::set_override(true);
}
pub fn is_debug() -> bool {
if let Ok(val) = env::var("OXIDITE_DEBUG") {
return val == "1" || val.to_lowercase() == "true";
}
false
}
pub fn success(msg: &str) {
println!("{} {}", "✓".green().bold(), msg);
}
pub fn info(msg: &str) {
println!("{} {}", "ℹ".blue().bold(), msg);
}
#[allow(dead_code)]
pub fn warning(msg: &str) {
println!("{} {}", "⚠".yellow().bold(), msg.yellow());
}
pub fn error(msg: &str) {
eprintln!("{} {}", "✗".red().bold(), msg.red());
}
pub fn header(msg: &str) {
println!("\n{}", msg.cyan().bold());
}
pub fn step(msg: &str) {
println!("{} {}", "»".cyan(), msg);
}
pub fn compile_error(msg: &str) {
eprintln!("{} {}", "error:".red().bold(), msg);
}
pub fn runtime_error(msg: &str) {
eprintln!("{} {}", "runtime error:".red().bold(), msg);
}
pub fn build_failed(msg: &str) {
eprintln!("\n{}", "Build failed:".red().bold());
eprintln!(" {}", msg.dimmed());
}
pub fn build_success(msg: &str) {
println!("\n{}", "Build succeeded:".green().bold());
println!(" {}", msg);
}
#[allow(dead_code)]
pub fn command_output(output: &str) {
println!("{}", output);
}
#[allow(dead_code)]
pub fn deprecated(old: &str, new: &str) {
warning(&format!(
"'{}' is deprecated, use '{}' instead",
old, new
));
}
pub fn debug(msg: &str) {
if is_debug() {
println!("[{}] {}", "DEBUG".bright_black().bold(), msg.dimmed());
}
}