diff options
| author | Luca Plian <98339220+AnonimAnonim2245@users.noreply.github.com> | 2024-03-15 14:51:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-15 13:51:24 +0100 |
| commit | 17ee0e3c7a47054baf5e66c5525541e4153c03b7 (patch) | |
| tree | cdeab440fc052a2290430d3f89d8ff096fee2ad7 /src/ui.rs | |
| parent | c46a7115265406330dc95fc7ab8e500cd8d24859 (diff) | |
optimized the UI code (#1830)
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -1,33 +1,28 @@ -macro_rules! warn { - ($fmt:literal, $ex:expr) => {{ +macro_rules! print_emoji { + ($emoji:expr, $sign:expr, $color: ident ,$fmt:literal, $ex:expr) => {{ use console::{style, Emoji}; use std::env; let formatstr = format!($fmt, $ex); if env::var("NO_EMOJI").is_ok() { - println!("{} {}", style("!").red(), style(formatstr).red()); + println!("{} {}", style($sign).$color(), style(formatstr).$color()); } else { println!( "{} {}", - style(Emoji("⚠️ ", "!")).red(), - style(formatstr).red() + style(Emoji($emoji, $sign)).$color(), + style(formatstr).$color() ); } }}; } +macro_rules! warn { + ($fmt:literal, $ex:expr) => {{ + print_emoji!("⚠️ ", "!", red, $fmt, $ex); + }}; +} + macro_rules! success { ($fmt:literal, $ex:expr) => {{ - use console::{style, Emoji}; - 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() - ); - } + print_emoji!("✅ ", "✓", green, $fmt, $ex); }}; } |
