Skip to content

Commit

Permalink
Collapse nested if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdouSeck committed Jun 4, 2020
1 parent 40741c5 commit 02a2fe4
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ fn main() {
.version(crate_version!())
.author("Olivia Hugger, Carol Nichols")
.about("Rustlings is a collection of small exercises to get you used to writing and reading Rust code")
.subcommand(SubCommand::with_name("verify").alias("v").about("Verifies all exercises according to the recommended order"))
.subcommand(SubCommand::with_name("watch").alias("w").about("Reruns `verify` when files were edited"))
.arg(
Arg::with_name("verbose")
.short("V")
.long("verbose")
.help("Show tests' standard output")
)
.subcommand(
SubCommand::with_name("verify")
.alias("v")
.about("Verifies all exercises according to the recommended order")
)
.subcommand(
SubCommand::with_name("watch")
.alias("w")
.about("Reruns `verify` when files were edited")
)
.subcommand(
SubCommand::with_name("run")
.alias("r")
Expand All @@ -43,7 +57,7 @@ fn main() {
)
.get_matches();

if None == matches.subcommand_name() {
if matches.subcommand_name().is_none() {
println!();
println!(r#" welcome to... "#);
println!(r#" _ _ _ "#);
Expand Down Expand Up @@ -105,22 +119,20 @@ fn main() {
verify(&exercises).unwrap_or_else(|_| std::process::exit(1));
}

if matches.subcommand_matches("watch").is_some() {
if watch(&exercises).is_ok() {
println!(
"{emoji} All exercises completed! {emoji}",
emoji = Emoji("🎉", "★")
);
println!("");
println!("We hope you enjoyed learning about the various aspects of Rust!");
println!(
"If you noticed any issues, please don't hesitate to report them to our repo."
);
println!("You can also contribute your own exercises to help the greater community!");
println!("");
println!("Before reporting an issue or contributing, please read our guidelines:");
println!("https://github.com/rust-lang/rustlings/blob/master/CONTRIBUTING.md");
}
if matches.subcommand_matches("watch").is_some() && watch(&exercises).is_ok() {
println!(
"{emoji} All exercises completed! {emoji}",
emoji = Emoji("🎉", "★")
);
println!();
println!("We hope you enjoyed learning about the various aspects of Rust!");
println!(
"If you noticed any issues, please don't hesitate to report them to our repo."
);
println!("You can also contribute your own exercises to help the greater community!");
println!();
println!("Before reporting an issue or contributing, please read our guidelines:");
println!("https://github.com/rust-lang/rustlings/blob/master/CONTRIBUTING.md");
}

if matches.subcommand_name().is_none() {
Expand Down

0 comments on commit 02a2fe4

Please sign in to comment.