Files
rush/src/error/colors.rs

38 lines
1.2 KiB
Rust

pub struct Colors;
impl Colors {
pub const RESET: &'static str = "\x1b[0m";
pub const BOLD: &'static str = "\x1b[1m";
pub const RED: &'static str = "\x1b[31m";
pub const GREEN: &'static str = "\x1b[32m";
pub const YELLOW: &'static str = "\x1b[33m";
pub const BLUE: &'static str = "\x1b[34m";
pub const MAGENTA: &'static str = "\x1b[35m";
pub const CYAN: &'static str = "\x1b[36m";
pub const BOLD_RED: &'static str = "\x1b[1;31m";
pub const BOLD_YELLOW: &'static str = "\x1b[1;33m";
pub const BOLD_CYAN: &'static str = "\x1b[1;36m";
}
pub fn error(msg: &str) -> String {
format!("{}{}ERROR:{} {}", Colors::BOLD_RED, Colors::BOLD, Colors::RESET, msg)
}
pub fn warning(msg: &str) -> String {
format!("{}{}WARNING:{} {}", Colors::BOLD_YELLOW, Colors::BOLD, Colors::RESET, msg)
}
pub fn info(msg: &str) -> String {
format!("{}{}INFO:{} {}", Colors::BOLD_CYAN, Colors::BOLD, Colors::RESET, msg)
}
pub fn location(file: &str, line: usize) -> String {
format!("{}{}:{}{}", Colors::CYAN, file, line, Colors::RESET)
}
pub fn highlight(text: &str) -> String {
format!("{}{}{}", Colors::YELLOW, text, Colors::RESET)
}