File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -80,9 +80,6 @@ fn main() {
80
80
}
81
81
82
82
if matches. subcommand_matches ( "watch" ) . is_some ( ) {
83
- /* Clears the terminal with an ANSI escape code.
84
- Works in UNIX and newer Windows terminals. */
85
- println ! ( "\x1B c" ) ;
86
83
watch ( & exercises) . unwrap ( ) ;
87
84
}
88
85
@@ -93,23 +90,30 @@ fn main() {
93
90
}
94
91
95
92
fn watch ( exercises : & [ Exercise ] ) -> notify:: Result < ( ) > {
93
+ /* Clears the terminal with an ANSI escape code.
94
+ Works in UNIX and newer Windows terminals. */
95
+ fn clear_screen ( ) {
96
+ println ! ( "\x1B c" ) ;
97
+ }
98
+
96
99
let ( tx, rx) = channel ( ) ;
97
100
98
101
let mut watcher: RecommendedWatcher = Watcher :: new ( tx, Duration :: from_secs ( 2 ) ) ?;
99
102
watcher. watch ( Path :: new ( "./exercises" ) , RecursiveMode :: Recursive ) ?;
100
103
104
+ clear_screen ( ) ;
101
105
let _ignored = verify ( exercises. iter ( ) ) ;
102
106
103
107
loop {
104
108
match rx. recv ( ) {
105
109
Ok ( event) => match event {
106
110
DebouncedEvent :: Create ( b) | DebouncedEvent :: Chmod ( b) | DebouncedEvent :: Write ( b) => {
107
111
if b. extension ( ) == Some ( OsStr :: new ( "rs" ) ) && b. exists ( ) {
108
- println ! ( "----------**********----------\n " ) ;
109
112
let filepath = b. as_path ( ) . canonicalize ( ) . unwrap ( ) ;
110
113
let exercise = exercises
111
114
. iter ( )
112
115
. skip_while ( |e| !filepath. ends_with ( & e. path ) ) ;
116
+ clear_screen ( ) ;
113
117
let _ignored = verify ( exercise) ;
114
118
}
115
119
}
You can’t perform that action at this time.
0 commit comments