1
0
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:
magnusrodseth
2022-08-17 16:31:53 +02:00
parent d0c7b06eff
commit 6f44cb1dd2
2 changed files with 74 additions and 19 deletions

View File

@ -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