1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-11-08 09:09:17 +01:00

feat: add "rustlings list" command

This commit is contained in:
Caleb Webber 2020-11-10 12:36:19 -05:00 committed by GitHub
parent 96347df9df
commit 838f9f3008
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

@ -54,6 +54,11 @@ fn main() {
.about("Returns a hint for the current exercise") .about("Returns a hint for the current exercise")
.arg(Arg::with_name("name").required(true).index(1)), .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(); .get_matches();
if matches.subcommand_name().is_none() { if matches.subcommand_name().is_none() {
@ -88,6 +93,9 @@ fn main() {
let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises; let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
let verbose = matches.is_present("nocapture"); 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") { if let Some(ref matches) = matches.subcommand_matches("run") {
let name = matches.value_of("name").unwrap(); let name = matches.value_of("name").unwrap();