File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -80,9 +80,6 @@ fn main() {
8080 }
8181
8282 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" ) ;
8683 watch ( & exercises) . unwrap ( ) ;
8784 }
8885
@@ -93,23 +90,30 @@ fn main() {
9390}
9491
9592fn 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+
9699 let ( tx, rx) = channel ( ) ;
97100
98101 let mut watcher: RecommendedWatcher = Watcher :: new ( tx, Duration :: from_secs ( 2 ) ) ?;
99102 watcher. watch ( Path :: new ( "./exercises" ) , RecursiveMode :: Recursive ) ?;
100103
104+ clear_screen ( ) ;
101105 let _ignored = verify ( exercises. iter ( ) ) ;
102106
103107 loop {
104108 match rx. recv ( ) {
105109 Ok ( event) => match event {
106110 DebouncedEvent :: Create ( b) | DebouncedEvent :: Chmod ( b) | DebouncedEvent :: Write ( b) => {
107111 if b. extension ( ) == Some ( OsStr :: new ( "rs" ) ) && b. exists ( ) {
108- println ! ( "----------**********----------\n " ) ;
109112 let filepath = b. as_path ( ) . canonicalize ( ) . unwrap ( ) ;
110113 let exercise = exercises
111114 . iter ( )
112115 . skip_while ( |e| !filepath. ends_with ( & e. path ) ) ;
116+ clear_screen ( ) ;
113117 let _ignored = verify ( exercise) ;
114118 }
115119 }
You can’t perform that action at this time.
0 commit comments