mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-16 09:08:37 +01:00
31 lines
628 B
Rust
31 lines
628 B
Rust
|
use miette::{IntoDiagnostic, Result};
|
||
|
use watchexec::Watchexec;
|
||
|
|
||
|
#[tokio::main]
|
||
|
async fn main() -> Result<()> {
|
||
|
let wx = Watchexec::new(|mut action| {
|
||
|
// you don't HAVE to spawn jobs:
|
||
|
// here, we just print out the events as they come in
|
||
|
for event in action.events.iter() {
|
||
|
eprintln!("{event:?}");
|
||
|
}
|
||
|
|
||
|
// quit when we get a signal
|
||
|
if action.signals().next().is_some() {
|
||
|
eprintln!("[Quitting...]");
|
||
|
action.quit();
|
||
|
}
|
||
|
|
||
|
action
|
||
|
})?;
|
||
|
|
||
|
// start the engine
|
||
|
let main = wx.main();
|
||
|
|
||
|
// and watch all files in the current directory:
|
||
|
wx.config.pathset(["."]);
|
||
|
|
||
|
let _ = main.await.into_diagnostic()?;
|
||
|
Ok(())
|
||
|
}
|