2018-05-14 17:13:13 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate quicli;
|
2018-05-06 16:59:50 +00:00
|
|
|
extern crate ansi_term;
|
|
|
|
|
2018-05-22 20:23:22 +00:00
|
|
|
use ansi_term::Color::{Green, Red, Yellow};
|
2018-05-16 13:30:30 +00:00
|
|
|
use quicli::prelude::*;
|
2018-05-22 20:23:22 +00:00
|
|
|
use std::fmt::Display;
|
|
|
|
|
|
|
|
pub fn verify<T: PartialEq + Display>(left: T, right: T) {
|
|
|
|
if left == right {
|
|
|
|
println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
|
|
|
|
} else {
|
|
|
|
println!(
|
|
|
|
"{} You submitted {}, but that's not correct!",
|
|
|
|
Red.bold().paint("FAIL"),
|
|
|
|
left
|
|
|
|
);
|
|
|
|
println!(" Please correct your code to make this test pass!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn verify_easy<T: PartialEq + Display>(left: T, right: T) {
|
|
|
|
if left == right {
|
|
|
|
println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
|
|
|
|
} else {
|
|
|
|
println!(
|
|
|
|
"{} You submitted {}, but that's not correct!",
|
|
|
|
Red.bold().paint("FAIL"),
|
|
|
|
left
|
|
|
|
);
|
|
|
|
println!(" Expected: {}", right);
|
|
|
|
println!(" Please correct your code to make this test pass!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn title(s: &str) {
|
|
|
|
println!("{} {}", Yellow.bold().paint("RUN"), s);
|
|
|
|
}
|
2018-05-14 16:41:58 +00:00
|
|
|
|
|
|
|
mod about_variables;
|
2018-05-06 16:59:50 +00:00
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
struct Cli {
|
|
|
|
exercise: Option<String>,
|
|
|
|
}
|
|
|
|
|
2018-05-14 17:13:13 +00:00
|
|
|
main!(|args: Cli| if let Some(e) = args.exercise {
|
|
|
|
println!("selected {}", e);
|
|
|
|
} else {
|
2018-05-16 13:27:57 +00:00
|
|
|
println!("Welcome to {}!\n", Yellow.paint("Rustlings"));
|
2018-05-16 13:23:14 +00:00
|
|
|
about_variables::exec();
|
2018-05-06 16:59:50 +00:00
|
|
|
});
|