File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ fn main() {
52
52
}
53
53
54
54
if matches. subcommand_matches ( "verify" ) . is_some ( ) {
55
- match verify ( ) {
55
+ match verify ( None ) {
56
56
Ok ( _) => { }
57
57
Err ( _) => std:: process:: exit ( 1 ) ,
58
58
}
@@ -81,14 +81,15 @@ fn watch() -> notify::Result<()> {
81
81
let mut watcher: RecommendedWatcher = Watcher :: new ( tx, Duration :: from_secs ( 2 ) ) ?;
82
82
watcher. watch ( "./exercises" , RecursiveMode :: Recursive ) ?;
83
83
84
- let _ignored = verify ( ) ;
84
+ let _ignored = verify ( None ) ;
85
85
86
86
loop {
87
87
match rx. recv ( ) {
88
88
Ok ( event) => match event {
89
89
DebouncedEvent :: Create ( b) | DebouncedEvent :: Chmod ( b) | DebouncedEvent :: Write ( b) => {
90
90
if b. extension ( ) == Some ( OsStr :: new ( "rs" ) ) {
91
- let _ignored = verify ( ) ;
91
+ println ! ( "----------**********----------\n " ) ;
92
+ let _ignored = verify ( Some ( b. as_path ( ) . to_str ( ) . unwrap ( ) ) ) ;
92
93
}
93
94
}
94
95
_ => { }
Original file line number Diff line number Diff line change @@ -5,13 +5,25 @@ use std::fs;
5
5
use std:: process:: Command ;
6
6
use toml:: Value ;
7
7
8
- pub fn verify ( ) -> Result < ( ) , ( ) > {
8
+ pub fn verify ( start_at : Option < & str > ) -> Result < ( ) , ( ) > {
9
9
let toml: Value = fs:: read_to_string ( "info.toml" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
10
10
let tomlvec: & Vec < Value > = toml. get ( "exercises" ) . unwrap ( ) . as_array ( ) . unwrap ( ) ;
11
+ let mut hit_start_at = false ;
12
+
11
13
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
+
12
24
match i. get ( "mode" ) . unwrap ( ) . as_str ( ) . unwrap ( ) {
13
- "test" => test ( i . get ( " path" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ) ?,
14
- "compile" => compile_only ( i . get ( " path" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ) ?,
25
+ "test" => test ( path) ?,
26
+ "compile" => compile_only ( path) ?,
15
27
_ => ( ) ,
16
28
}
17
29
}
You can’t perform that action at this time.
0 commit comments