feat(cli): Add "next" to run the next unsolved exercise. (#785)
* Add "run next" to run the next unsolved exercise. * Fix a grammar error in the message. * Update README.md with the suggested change Co-authored-by: marisa <mokou@fastmail.com> * Update the README.md for "rustlings hint next". Co-authored-by: marisa <mokou@fastmail.com>
This commit is contained in:
parent
633303d4b8
commit
d20e413a68
12
README.md
12
README.md
@ -97,6 +97,12 @@ In case you want to go by your own order, or want to only verify a single exerci
|
|||||||
rustlings run myExercise1
|
rustlings run myExercise1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or simply use the following command to run the next unsolved exercise in the course:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustlings run next
|
||||||
|
```
|
||||||
|
|
||||||
In case you get stuck, you can run the following command to get a hint for your
|
In case you get stuck, you can run the following command to get a hint for your
|
||||||
exercise:
|
exercise:
|
||||||
|
|
||||||
@ -104,6 +110,12 @@ exercise:
|
|||||||
rustlings hint myExercise1
|
rustlings hint myExercise1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also get the hint for the next unsolved exercise with the following command:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
rustlings hint next
|
||||||
|
```
|
||||||
|
|
||||||
To check your progress, you can run the following command:
|
To check your progress, you can run the following command:
|
||||||
```bash
|
```bash
|
||||||
rustlings list
|
rustlings list
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -286,6 +286,16 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
||||||
|
if name.eq("next") {
|
||||||
|
exercises
|
||||||
|
.iter()
|
||||||
|
.find(|e| !e.looks_done())
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
println!("🎉 Congratulations! You have done all the exercises!");
|
||||||
|
println!("🔚 There are no more exercises to do next!");
|
||||||
|
std::process::exit(1)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
exercises
|
exercises
|
||||||
.iter()
|
.iter()
|
||||||
.find(|e| e.name == name)
|
.find(|e| e.name == name)
|
||||||
@ -293,6 +303,7 @@ fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
|||||||
println!("No exercise found for '{}'!", name);
|
println!("No exercise found for '{}'!", name);
|
||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> {
|
fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> {
|
||||||
|
Reference in New Issue
Block a user