Skip to content

Commit 838f9f3

Browse files
authored
feat: add "rustlings list" command
1 parent 96347df commit 838f9f3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ fn main() {
5454
.about("Returns a hint for the current exercise")
5555
.arg(Arg::with_name("name").required(true).index(1)),
5656
)
57+
.subcommand(
58+
SubCommand::with_name("list")
59+
.alias("l")
60+
.about("Lists the exercises available in rustlings")
61+
)
5762
.get_matches();
5863

5964
if matches.subcommand_name().is_none() {
@@ -88,6 +93,9 @@ fn main() {
8893
let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
8994
let verbose = matches.is_present("nocapture");
9095

96+
if matches.subcommand_matches("list").is_some() {
97+
exercises.iter().for_each(|e| println!("{}", e.name));
98+
}
9199
if let Some(ref matches) = matches.subcommand_matches("run") {
92100
let name = matches.value_of("name").unwrap();
93101

0 commit comments

Comments
 (0)