mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-11-08 09:09:17 +01:00
color output messages
This commit is contained in:
parent
18a1447a65
commit
b3c52803e9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,4 @@
|
|||||||
*.swp
|
*.swp
|
||||||
target/
|
target/
|
||||||
|
|
||||||
/target/
|
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -85,10 +85,12 @@ fn compile_only(filename: &str) {
|
|||||||
.expect("fail");
|
.expect("fail");
|
||||||
bar.finish_and_clear();
|
bar.finish_and_clear();
|
||||||
if compilecmd.status.success() {
|
if compilecmd.status.success() {
|
||||||
println!("{} Successfully compiled {}!", Emoji("✅", "✓"), style(filename).italic());
|
let formatstr = format!("{} Successfully compiled {}!", Emoji("✅", "✓"), filename);
|
||||||
|
println!("{}", style(formatstr).green());
|
||||||
clean().unwrap();
|
clean().unwrap();
|
||||||
} else {
|
} else {
|
||||||
println!("{} Compilation of {} failed! Compiler error message:\n", Emoji("⚠️ ", "!"), style(filename).italic());
|
let formatstr = format!("{} Compilation of {} failed! Compiler error message:\n", Emoji("⚠️ ", "!"), filename);
|
||||||
|
println!("{}", style(formatstr).red());
|
||||||
println!("{}", String::from_utf8_lossy(&compilecmd.stderr));
|
println!("{}", String::from_utf8_lossy(&compilecmd.stderr));
|
||||||
clean().unwrap();
|
clean().unwrap();
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
@ -105,10 +107,12 @@ fn test(filename: &str) {
|
|||||||
.expect("fail");
|
.expect("fail");
|
||||||
bar.finish_and_clear();
|
bar.finish_and_clear();
|
||||||
if testcmd.status.success() {
|
if testcmd.status.success() {
|
||||||
println!("{} Successfully tested {}!", Emoji("✅", "✓"), style(filename).italic());
|
let formatstr = format!("{} Successfully tested {}!", Emoji("✅", "✓"), filename);
|
||||||
|
println!("{}", style(formatstr).green());
|
||||||
clean().unwrap();
|
clean().unwrap();
|
||||||
} else {
|
} else {
|
||||||
println!("{} Testing of {} failed! Please try again.", Emoji("⚠️ ", "!"), style(filename).italic());
|
let formatstr = format!("{} Testing of {} failed! Please try again.", Emoji("⚠️ ", "!"), filename);
|
||||||
|
println!("{}", style(formatstr).red());
|
||||||
clean().unwrap();
|
clean().unwrap();
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user