From 668efe89baebc9231c72cc890452c02bf1403ef8 Mon Sep 17 00:00:00 2001 From: Caleb Webber <caleb@codingthemsoftly.com> Date: Thu, 5 Nov 2020 18:55:37 -0500 Subject: [PATCH] feat: Add "rustlings list" feature closes #576 --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index b5814bf..96d2780 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,11 @@ fn main() { .about("Returns a hint for the current exercise") .arg(Arg::with_name("name").required(true).index(1)), ) + .subcommand( + SubCommand::with_name("list") + .alias("l") + .about("Lists the exercises available in rustlings") + ) .get_matches(); if matches.subcommand_name().is_none() { @@ -88,6 +93,9 @@ fn main() { let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises; let verbose = matches.is_present("nocapture"); + if matches.subcommand_matches("list").is_some() { + exercises.iter().for_each(|e| println!("{}", e.name)); + } if let Some(ref matches) = matches.subcommand_matches("run") { let name = matches.value_of("name").unwrap();