This commit is contained in:
olivia 2018-11-14 20:12:20 +01:00
parent b8789f09e0
commit 6baac88574
1 changed files with 113 additions and 100 deletions

View File

@ -1,13 +1,13 @@
#[macro_use] #[macro_use]
extern crate clap; extern crate clap;
extern crate indicatif;
extern crate console; extern crate console;
extern crate indicatif;
use clap::{App, SubCommand}; use clap::{App, SubCommand};
use indicatif::{ProgressBar};
use console::{style, Emoji}; use console::{style, Emoji};
use std::process::Command; use indicatif::ProgressBar;
use std::fs::remove_file; use std::fs::remove_file;
use std::process::Command;
fn main() { fn main() {
let matches = App::new("r2") let matches = App::new("r2")
@ -15,6 +15,7 @@ fn main() {
.author("Olivia Hugger") .author("Olivia Hugger")
.about("Test") .about("Test")
.subcommand(SubCommand::with_name("verify").alias("v")) .subcommand(SubCommand::with_name("verify").alias("v"))
.subcommand(SubCommand::with_name("run").alias("r"))
.get_matches(); .get_matches();
println!(r#" _ _ _ "#); println!(r#" _ _ _ "#);
@ -93,11 +94,19 @@ 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() {
let formatstr = format!("{} Successfully compiled {}!", Emoji("", ""), filename); let formatstr = format!(
"{} Successfully compiled {}!",
Emoji("", ""),
filename
);
println!("{}", style(formatstr).green()); println!("{}", style(formatstr).green());
clean().unwrap(); clean().unwrap();
} else { } else {
let formatstr = format!("{} Compilation of {} failed! Compiler error message:\n", Emoji("⚠️ ", "!"), filename); let formatstr = format!(
"{} Compilation of {} failed! Compiler error message:\n",
Emoji("⚠️ ", "!"),
filename
);
println!("{}", style(formatstr).red()); println!("{}", style(formatstr).red());
println!("{}", String::from_utf8_lossy(&compilecmd.stderr)); println!("{}", String::from_utf8_lossy(&compilecmd.stderr));
clean().unwrap(); clean().unwrap();
@ -119,7 +128,11 @@ fn test(filename: &str) {
println!("{}", style(formatstr).green()); println!("{}", style(formatstr).green());
clean().unwrap(); clean().unwrap();
} else { } else {
let formatstr = format!("{} Testing of {} failed! Please try again.", Emoji("⚠️ ", "!"), filename); let formatstr = format!(
"{} Testing of {} failed! Please try again.",
Emoji("⚠️ ", "!"),
filename
);
println!("{}", style(formatstr).red()); println!("{}", style(formatstr).red());
clean().unwrap(); clean().unwrap();
std::process::exit(1); std::process::exit(1);