From 47f0b94d0c6f5b03d85e55ea19bf2cd5e91a420c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 19 Apr 2021 13:05:34 -0700 Subject: [PATCH] Add an example executable for fsevents --- fsevent/examples/events.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 fsevent/examples/events.rs diff --git a/fsevent/examples/events.rs b/fsevent/examples/events.rs new file mode 100644 index 0000000000..7f064d9050 --- /dev/null +++ b/fsevent/examples/events.rs @@ -0,0 +1,16 @@ +use fsevent::EventStream; +use std::{env::args, path::Path, time::Duration}; + +fn main() { + let paths = args().skip(1).collect::>(); + let paths = paths.iter().map(Path::new).collect::>(); + assert!(paths.len() > 0, "Must pass 1 or more paths as arguments"); + let stream = EventStream::new(&paths, Duration::from_millis(100), |events| { + eprintln!("event batch"); + for event in events { + eprintln!(" {:?}", event); + } + true + }); + stream.run(); +}