diff options
| author | bors <bors@rust-lang.org> | 2019-11-09 15:23:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-09 15:23:53 +0000 |
| commit | 3232a4d60d45381f0b5b2319b7cb5ba78cc513ac (patch) | |
| tree | 4e97e13e830d7a5b7aff7871db00ffb4ed9e33e6 | |
| parent | c8babbad27550a8920d4442fbd3cc155bcaf622c (diff) | |
| parent | 3aff59085586c24196a547c2693adbdcf4432648 (diff) | |
Auto merge of #228 - WofWca:clear-screen, r=fmoko
improvement(watch): clear screen before each `verify()`
Closes #146
It seems to me that #227 wasn't really fixing the issue.
| -rw-r--r-- | src/main.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 857d34e..aad4cff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,9 +80,6 @@ fn main() { } if matches.subcommand_matches("watch").is_some() { - /* Clears the terminal with an ANSI escape code. - Works in UNIX and newer Windows terminals. */ - println!("\x1Bc"); watch(&exercises).unwrap(); } @@ -93,11 +90,18 @@ fn main() { } fn watch(exercises: &[Exercise]) -> notify::Result<()> { + /* Clears the terminal with an ANSI escape code. + Works in UNIX and newer Windows terminals. */ + fn clear_screen() { + println!("\x1Bc"); + } + let (tx, rx) = channel(); let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2))?; watcher.watch(Path::new("./exercises"), RecursiveMode::Recursive)?; + clear_screen(); let _ignored = verify(exercises.iter()); loop { @@ -105,11 +109,11 @@ fn watch(exercises: &[Exercise]) -> notify::Result<()> { Ok(event) => match event { DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => { if b.extension() == Some(OsStr::new("rs")) && b.exists() { - println!("----------**********----------\n"); let filepath = b.as_path().canonicalize().unwrap(); let exercise = exercises .iter() .skip_while(|e| !filepath.ends_with(&e.path)); + clear_screen(); let _ignored = verify(exercise); } } |
