PrettyPrompt/src/indicators/error.rs
2024-11-25 13:23:37 +05:30

18 lines
616 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use ansi_term::ANSIGenericString;
use ansi_term::Colour::RGB;
// Error indicator symbol
pub const ERR_SYMBOL: &str = "\u{276F}"; // ""
pub const ERR_COL: ansi_term::Colour = RGB(255, 53, 94); //
pub const NORMIE_COL: ansi_term::Colour = RGB(0, 255, 180); //
// Error indicator
pub fn indicator(args: Vec<String>) -> ANSIGenericString<'static, str> {
let default_exit_code = "0".to_string();
let exit_code = args.get(1).unwrap_or(&default_exit_code); // Default to "0" if missing
match exit_code.as_str() {
"0" => NORMIE_COL.paint(ERR_SYMBOL),
_ => ERR_COL.paint(ERR_SYMBOL),
}
}