refactor: change from match to if for NO_EMOJI
This commit is contained in:
parent
8d62a99637
commit
01e7f27aa6
@ -127,9 +127,10 @@ name = "{}"
|
|||||||
path = "{}.rs""#,
|
path = "{}.rs""#,
|
||||||
self.name, self.name, self.name
|
self.name, self.name, self.name
|
||||||
);
|
);
|
||||||
let cargo_toml_error_msg = match env::var("NO_EMOJI").is_ok() {
|
let cargo_toml_error_msg = if env::var("NO_EMOJI").is_ok() {
|
||||||
true => "Failed to write Clippy Cargo.toml file.",
|
"Failed to write Clippy Cargo.toml file."
|
||||||
false => "Failed to write 📎 Clippy 📎 Cargo.toml file."
|
} else {
|
||||||
|
"Failed to write 📎 Clippy 📎 Cargo.toml file."
|
||||||
};
|
};
|
||||||
fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml)
|
fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml)
|
||||||
.expect(cargo_toml_error_msg);
|
.expect(cargo_toml_error_msg);
|
||||||
|
14
src/ui.rs
14
src/ui.rs
@ -3,22 +3,19 @@ macro_rules! warn {
|
|||||||
use std::env;
|
use std::env;
|
||||||
use console::{style, Emoji};
|
use console::{style, Emoji};
|
||||||
let formatstr = format!($fmt, $ex);
|
let formatstr = format!($fmt, $ex);
|
||||||
match env::var("NO_EMOJI").is_ok() {
|
if env::var("NO_EMOJI").is_ok() {
|
||||||
true => {
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style("!").red(),
|
style("!").red(),
|
||||||
style(formatstr).red()
|
style(formatstr).red()
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
false => {
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style(Emoji("⚠️ ", "!")).red(),
|
style(Emoji("⚠️ ", "!")).red(),
|
||||||
style(formatstr).red()
|
style(formatstr).red()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,21 +24,18 @@ macro_rules! success {
|
|||||||
use std::env;
|
use std::env;
|
||||||
use console::{style, Emoji};
|
use console::{style, Emoji};
|
||||||
let formatstr = format!($fmt, $ex);
|
let formatstr = format!($fmt, $ex);
|
||||||
match env::var("NO_EMOJI").is_ok() {
|
if env::var("NO_EMOJI").is_ok() {
|
||||||
true => {
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style("✓").green(),
|
style("✓").green(),
|
||||||
style(formatstr).green()
|
style(formatstr).green()
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
false => {
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style(Emoji("✅", "✓")).green(),
|
style(Emoji("✅", "✓")).green(),
|
||||||
style(formatstr).green()
|
style(formatstr).green()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,10 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option<String>) ->
|
|||||||
|
|
||||||
let no_emoji = env::var("NO_EMOJI").is_ok();
|
let no_emoji = env::var("NO_EMOJI").is_ok();
|
||||||
|
|
||||||
let clippy_success_msg = match no_emoji {
|
let clippy_success_msg = if no_emoji {
|
||||||
true => "The code is compiling, and Clippy is happy!",
|
"The code is compiling, and Clippy is happy!"
|
||||||
false => "The code is compiling, and 📎 Clippy 📎 is happy!"
|
} else {
|
||||||
|
"The code is compiling, and 📎 Clippy 📎 is happy!"
|
||||||
};
|
};
|
||||||
|
|
||||||
let success_msg = match exercise.mode {
|
let success_msg = match exercise.mode {
|
||||||
@ -152,10 +153,11 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option<String>) ->
|
|||||||
};
|
};
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
match no_emoji {
|
if no_emoji {
|
||||||
true => println!("~*~ {} ~*~", success_msg),
|
println!("~*~ {} ~*~", success_msg)
|
||||||
false => println!("🎉 🎉 {} 🎉 🎉", success_msg)
|
} else {
|
||||||
};
|
println!("🎉 🎉 {} 🎉 🎉", success_msg)
|
||||||
|
}
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
if let Some(output) = prompt_output {
|
if let Some(output) = prompt_output {
|
||||||
|
Reference in New Issue
Block a user