mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Merge ce1a1d1e5a
into d8ecf4bc2d
This commit is contained in:
commit
8cb29fc2a2
|
@ -1,6 +1,6 @@
|
|||
use crate::exercise::{Exercise, ExerciseList};
|
||||
use crate::project::RustAnalyzerProject;
|
||||
use crate::run::{reset, run};
|
||||
use crate::run::{reset, reset_all, run};
|
||||
use crate::verify::verify;
|
||||
use clap::{Parser, Subcommand};
|
||||
use console::Emoji;
|
||||
|
@ -56,6 +56,7 @@ enum Subcommands {
|
|||
/// The name of the exercise
|
||||
name: String,
|
||||
},
|
||||
ResetAll {},
|
||||
/// Return a hint for the given exercise
|
||||
Hint {
|
||||
/// The name of the exercise
|
||||
|
@ -184,6 +185,9 @@ fn main() {
|
|||
|
||||
run(exercise, verbose).unwrap_or_else(|_| std::process::exit(1));
|
||||
}
|
||||
Subcommands::ResetAll {} => {
|
||||
reset_all(&exercises).unwrap_or_else(|_| std::process::exit(1));
|
||||
}
|
||||
|
||||
Subcommands::Reset { name } => {
|
||||
let exercise = find_exercise(&name, &exercises);
|
||||
|
|
15
src/run.rs
15
src/run.rs
|
@ -31,6 +31,21 @@ pub fn reset(exercise: &Exercise) -> Result<(), ()> {
|
|||
}
|
||||
}
|
||||
|
||||
//Resets all exercises by stashing the changes
|
||||
pub fn reset_all(exercises: &[Exercise]) -> Result<(), ()> {
|
||||
for exercise in exercises {
|
||||
let command = Command::new("git")
|
||||
.args(["stash", "push", "--"])
|
||||
.arg(&exercise.path)
|
||||
.spawn();
|
||||
|
||||
if command.is_err() {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Invoke the rust compiler on the path of the given exercise
|
||||
// and run the ensuing binary.
|
||||
// This is strictly for non-test binaries, so output is displayed
|
||||
|
|
Loading…
Reference in a new issue