summaryrefslogtreecommitdiff
path: root/src/ui.rs
diff options
context:
space:
mode:
authorMatt Lebl <lebl.matt@gmail.com>2021-03-19 02:16:07 -0700
committerMatt Lebl <lebl.matt@gmail.com>2021-03-19 02:16:07 -0700
commit8d62a9963708dbecd9312e8bcc4b47049c72d155 (patch)
tree3c5b973e1f1250624b709544e0d60bd607bf87a1 /src/ui.rs
parent0d894e6ff739943901e1ae8c904582e5c2f843bd (diff)
feat: Replace emojis when NO_EMOJI env variable present
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 38cbaa4..7ab8754 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -1,23 +1,47 @@
macro_rules! warn {
($fmt:literal, $ex:expr) => {{
+ use std::env;
use console::{style, Emoji};
let formatstr = format!($fmt, $ex);
- println!(
- "{} {}",
- style(Emoji("⚠️ ", "!")).red(),
- style(formatstr).red()
- );
+ match env::var("NO_EMOJI").is_ok() {
+ true => {
+ println!(
+ "{} {}",
+ style("!").red(),
+ style(formatstr).red()
+ );
+ },
+ false => {
+ println!(
+ "{} {}",
+ style(Emoji("⚠️ ", "!")).red(),
+ style(formatstr).red()
+ );
+ }
+ }
}};
}
macro_rules! success {
($fmt:literal, $ex:expr) => {{
+ use std::env;
use console::{style, Emoji};
let formatstr = format!($fmt, $ex);
- println!(
- "{} {}",
- style(Emoji("✅", "✓")).green(),
- style(formatstr).green()
- );
+ match env::var("NO_EMOJI").is_ok() {
+ true => {
+ println!(
+ "{} {}",
+ style("✓").green(),
+ style(formatstr).green()
+ );
+ },
+ false => {
+ println!(
+ "{} {}",
+ style(Emoji("✅", "✓")).green(),
+ style(formatstr).green()
+ );
+ }
+ }
}};
}