optimized the UI code

This commit is contained in:
AnonimAnonim2245 2024-01-18 14:55:45 +02:00
parent 8d0aa11a35
commit 971ff5412a

View File

@ -1,33 +1,28 @@
macro_rules! warn { macro_rules! print_emoji {
($fmt:literal, $ex:expr) => {{ ($emoji:expr, $sign:expr, $color: ident ,$fmt:literal, $ex:expr) => {{
use console::{style, Emoji}; use console::{style, Emoji};
use std::env; use std::env;
let formatstr = format!($fmt, $ex); let formatstr = format!($fmt, $ex);
if env::var("NO_EMOJI").is_ok() { if env::var("NO_EMOJI").is_ok() {
println!("{} {}", style("!").red(), style(formatstr).red()); println!("{} {}", style($sign).$color(), style(formatstr).$color());
} else { } else {
println!( println!(
"{} {}", "{} {}",
style(Emoji("⚠️ ", "!")).red(), style(Emoji($emoji, $sign)).$color(),
style(formatstr).red() style(formatstr).$color()
); );
} }
}}; }};
} }
macro_rules! warn {
($fmt:literal, $ex:expr) => {{
print_emoji!("⚠️ ", "!", red, $fmt ,$ex);
}}
}
macro_rules! success { macro_rules! success {
($fmt:literal, $ex:expr) => {{ ($fmt:literal, $ex:expr) => {{
use console::{style, Emoji}; print_emoji!("", "", green, $fmt ,$ex);
use std::env;
let formatstr = format!($fmt, $ex);
if env::var("NO_EMOJI").is_ok() {
println!("{} {}", style("").green(), style(formatstr).green());
} else {
println!(
"{} {}",
style(Emoji("", "")).green(),
style(formatstr).green()
);
}
}}; }};
} }