2018-05-06 12:59:50 -04:00
|
|
|
#[macro_use] extern crate quicli;
|
|
|
|
extern crate ansi_term;
|
|
|
|
|
|
|
|
use quicli::prelude::*;
|
2018-05-14 12:41:58 -04:00
|
|
|
use ansi_term::Colour::{Red, Yellow, Green};
|
|
|
|
|
|
|
|
macro_rules! verify {
|
|
|
|
( $str:expr, $left:expr, $right:expr ) => {
|
|
|
|
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!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! verify_easy {
|
|
|
|
( $str:expr, $left:expr, $right:expr ) => {
|
|
|
|
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!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod about_variables;
|
2018-05-06 12:59:50 -04:00
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
struct Cli {
|
|
|
|
exercise: Option<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
main!(|args: Cli| {
|
2018-05-14 12:41:58 -04:00
|
|
|
if let Some(e) = args.exercise {
|
|
|
|
println!("selected {}", e);
|
|
|
|
} else {
|
|
|
|
println!("Welcome to {}", Yellow.paint("rustlings"));
|
|
|
|
verify!("One equals one", 1, 2);
|
2018-05-06 12:59:50 -04:00
|
|
|
}
|
|
|
|
});
|