From 971ff5412a2b98e8aac99c801314b90a044bd391 Mon Sep 17 00:00:00 2001 From: AnonimAnonim2245 Date: Thu, 18 Jan 2024 14:55:45 +0200 Subject: [PATCH 1/4] optimized the UI code --- src/ui.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 1ee463168d..ffb5373300 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -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); }}; } From 3fc3423f7e616c6a381205f0b9ce41dd6b93fe21 Mon Sep 17 00:00:00 2001 From: AnonimAnonim2245 Date: Thu, 18 Jan 2024 14:59:25 +0200 Subject: [PATCH 2/4] optimized the UI code --- src/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui.rs b/src/ui.rs index ffb5373300..faaef2938f 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -18,7 +18,7 @@ macro_rules! print_emoji { macro_rules! warn { ($fmt:literal, $ex:expr) => {{ print_emoji!("⚠️ ", "!", red, $fmt ,$ex); - }} + }}; } macro_rules! success { From 236db88d7a41613a7ea13d26c29218dc24b8cd8d Mon Sep 17 00:00:00 2001 From: AnonimAnonim2245 Date: Thu, 18 Jan 2024 15:01:19 +0200 Subject: [PATCH 3/4] optimized the UI code --- src/ui.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index faaef2938f..9661f7b25d 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -17,12 +17,12 @@ macro_rules! print_emoji { macro_rules! warn { ($fmt:literal, $ex:expr) => {{ - print_emoji!("⚠️ ", "!", red, $fmt ,$ex); + print_emoji!("⚠️ ", "!", red, $fmt, $ex); }}; } macro_rules! success { ($fmt:literal, $ex:expr) => {{ - print_emoji!("✅ ", "✓", green, $fmt ,$ex); + print_emoji!("✅ ", "✓", green, $fmt, $ex); }}; -} +} \ No newline at end of file From 3ecadb74ac650a043ebebac36b78a0e01ee70d44 Mon Sep 17 00:00:00 2001 From: AnonimAnonim2245 Date: Thu, 18 Jan 2024 15:02:47 +0200 Subject: [PATCH 4/4] optimized the UI code --- src/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui.rs b/src/ui.rs index 9661f7b25d..74835e136c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -25,4 +25,4 @@ macro_rules! success { ($fmt:literal, $ex:expr) => {{ print_emoji!("✅ ", "✓", green, $fmt, $ex); }}; -} \ No newline at end of file +}