Skip to content

Commit 3f114cc

Browse files
committed
Start verification at most recently modified file
1 parent abf1751 commit 3f114cc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn main() {
5252
}
5353

5454
if matches.subcommand_matches("verify").is_some() {
55-
match verify() {
55+
match verify(None) {
5656
Ok(_) => {}
5757
Err(_) => std::process::exit(1),
5858
}
@@ -81,14 +81,14 @@ fn watch() -> notify::Result<()> {
8181
let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2))?;
8282
watcher.watch("./exercises", RecursiveMode::Recursive)?;
8383

84-
let _ignored = verify();
84+
let _ignored = verify(None);
8585

8686
loop {
8787
match rx.recv() {
8888
Ok(event) => match event {
8989
DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
9090
if b.extension() == Some(OsStr::new("rs")) {
91-
let _ignored = verify();
91+
let _ignored = verify(Some(b.as_path().to_str().unwrap()));
9292
}
9393
}
9494
_ => {}

src/verify.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ use std::fs;
55
use std::process::Command;
66
use toml::Value;
77

8-
pub fn verify() -> Result<(), ()> {
8+
pub fn verify(start_at: Option<&str>) -> Result<(), ()> {
99
let toml: Value = fs::read_to_string("info.toml").unwrap().parse().unwrap();
1010
let tomlvec: &Vec<Value> = toml.get("exercises").unwrap().as_array().unwrap();
11+
let mut hit_start_at = false;
12+
1113
for i in tomlvec {
14+
let path = i.get("path").unwrap().as_str().unwrap();
15+
16+
if let Some(start_at) = start_at {
17+
if start_at.ends_with(path) {
18+
hit_start_at = true;
19+
} else if !hit_start_at {
20+
continue;
21+
}
22+
}
23+
1224
match i.get("mode").unwrap().as_str().unwrap() {
1325
"test" => test(i.get("path").unwrap().as_str().unwrap())?,
1426
"compile" => compile_only(i.get("path").unwrap().as_str().unwrap())?,

0 commit comments

Comments
 (0)