mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-06-29 00:41:42 +02:00
feat: Add reset command, given a filename
This commit is contained in:
15
src/run.rs
15
src/run.rs
@ -1,3 +1,5 @@
|
||||
use std::process::Command;
|
||||
|
||||
use crate::exercise::{Exercise, Mode};
|
||||
use crate::verify::test;
|
||||
use indicatif::ProgressBar;
|
||||
@ -15,6 +17,19 @@ pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Resets the exercise by stashing the changes.
|
||||
pub fn reset(exercise: &Exercise) -> Result<(), ()> {
|
||||
let command = Command::new("git")
|
||||
.args(["stash", "--"])
|
||||
.arg(&exercise.path)
|
||||
.spawn();
|
||||
|
||||
match command {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
Reference in New Issue
Block a user