This commit is contained in:
olivia 2018-05-14 19:13:13 +02:00
parent 97efff760d
commit 8ea1b17fd9
1 changed files with 12 additions and 13 deletions

View File

@ -1,11 +1,12 @@
#[macro_use] extern crate quicli; #[macro_use]
extern crate quicli;
extern crate ansi_term; extern crate ansi_term;
use ansi_term::Colour::{Green, Red, Yellow};
use quicli::prelude::*; use quicli::prelude::*;
use ansi_term::Colour::{Red, Yellow, Green};
macro_rules! verify { macro_rules! verify {
( $str:expr, $left:expr, $right:expr ) => { ($left:expr, $right:expr, $str:expr) => {
if ($left == $right) { if ($left == $right) {
println!("{} {}", Green.bold().paint("PASS"), $str); println!("{} {}", Green.bold().paint("PASS"), $str);
} else { } else {
@ -13,11 +14,11 @@ macro_rules! verify {
println!("\tYou submitted {}, but that's not correct!", $left); println!("\tYou submitted {}, but that's not correct!", $left);
println!("\tPlease correct your code to make this test pass!"); println!("\tPlease correct your code to make this test pass!");
} }
} };
} }
macro_rules! verify_easy { macro_rules! verify_easy {
( $str:expr, $left:expr, $right:expr ) => { ($str:expr, $left:expr, $right:expr) => {
if ($left == $right) { if ($left == $right) {
println!("{} {}", Green.bold().paint("PASS"), $str); println!("{} {}", Green.bold().paint("PASS"), $str);
} else { } else {
@ -26,7 +27,7 @@ macro_rules! verify_easy {
println!("\tGot: {}", $left); println!("\tGot: {}", $left);
println!("\tPlease correct your code to make this test pass!"); println!("\tPlease correct your code to make this test pass!");
} }
} };
} }
mod about_variables; mod about_variables;
@ -36,11 +37,9 @@ struct Cli {
exercise: Option<String>, exercise: Option<String>,
} }
main!(|args: Cli| { main!(|args: Cli| if let Some(e) = args.exercise {
if let Some(e) = args.exercise { println!("selected {}", e);
println!("selected {}", e); } else {
} else { println!("Welcome to {}", Yellow.paint("rustlings"));
println!("Welcome to {}", Yellow.paint("rustlings")); verify!(2, 1, "One equals one");
verify!("One equals one", 1, 2);
}
}); });