2018-05-14 19:13:13 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate quicli;
|
2018-05-06 18:59:50 +02:00
|
|
|
extern crate ansi_term;
|
|
|
|
|
2018-05-14 19:13:13 +02:00
|
|
|
use ansi_term::Colour::{Green, Red, Yellow};
|
2018-05-06 18:59:50 +02:00
|
|
|
use quicli::prelude::*;
|
2018-05-14 18:41:58 +02:00
|
|
|
|
|
|
|
macro_rules! verify {
|
2018-05-14 19:13:13 +02:00
|
|
|
($left:expr, $right:expr, $str:expr) => {
|
2018-05-14 18:41:58 +02:00
|
|
|
if ($left == $right) {
|
|
|
|
println!("{} {}", Green.bold().paint("PASS"), $str);
|
|
|
|
} else {
|
|
|
|
println!("{} {}", Red.bold().paint("FAIL"), $str);
|
|
|
|
println!("\tYou submitted {}, but that's not correct!", $left);
|
|
|
|
println!("\tPlease correct your code to make this test pass!");
|
|
|
|
}
|
2018-05-14 19:13:13 +02:00
|
|
|
};
|
2018-05-14 18:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! verify_easy {
|
2018-05-14 19:13:13 +02:00
|
|
|
($str:expr, $left:expr, $right:expr) => {
|
2018-05-14 18:41:58 +02:00
|
|
|
if ($left == $right) {
|
|
|
|
println!("{} {}", Green.bold().paint("PASS"), $str);
|
|
|
|
} else {
|
|
|
|
println!("{} {}", Red.bold().paint("FAIL"), $str);
|
|
|
|
println!("\tExpected: {}", $right);
|
|
|
|
println!("\tGot: {}", $left);
|
|
|
|
println!("\tPlease correct your code to make this test pass!");
|
|
|
|
}
|
2018-05-14 19:13:13 +02:00
|
|
|
};
|
2018-05-14 18:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mod about_variables;
|
2018-05-06 18:59:50 +02:00
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
struct Cli {
|
|
|
|
exercise: Option<String>,
|
|
|
|
}
|
|
|
|
|
2018-05-14 19:13:13 +02:00
|
|
|
main!(|args: Cli| if let Some(e) = args.exercise {
|
|
|
|
println!("selected {}", e);
|
|
|
|
} else {
|
|
|
|
println!("Welcome to {}", Yellow.paint("rustlings"));
|
|
|
|
verify!(2, 1, "One equals one");
|
2018-05-06 18:59:50 +02:00
|
|
|
});
|