summaryrefslogtreecommitdiff
path: root/src/run.rs
diff options
context:
space:
mode:
authormagnusrodseth <59113973+magnusrodseth@users.noreply.github.com>2022-08-17 16:31:53 +0200
committermagnusrodseth <59113973+magnusrodseth@users.noreply.github.com>2022-08-17 16:31:53 +0200
commit6f44cb1dd237f4d53aa3ecd4676e50cf850c99fe (patch)
treecd74cefb493ec715c13b4f0bdb0bc47c9bd0cf98 /src/run.rs
parentd0c7b06eff3e8959b261145e10f1aaa57ba1e4c3 (diff)
feat: Add reset command, given a filename
Diffstat (limited to 'src/run.rs')
-rw-r--r--src/run.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/run.rs b/src/run.rs
index eb55885..826f00a 100644
--- a/src/run.rs
+++ b/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