Crates.io page API Docs Crate license: Apache 2.0 MSRV: 1.43.0 (breaking) CI status

Watchexec library

The library which powers Watchexec CLI and other tools.

Quick start

```rust use watchexec::{ config::ConfigBuilder, error::Result, pathop::PathOp, run::{ ExecHandler, Handler, watch, }, };

fn main() -> Result<()> { let config = ConfigBuilder::default() .clearscreen(true) .runinitially(true) .paths(vec![ "/path/to/dir".into() ]) .cmd(vec![ "date; seq 1 10".into() ]) .build()?;

let handler = MyHandler(ExecHandler::new(options)?);
watch(&handler)

}

struct MyHandler(ExecHandler);

impl Handler for MyHandler { fn args(&self) -> Config { self.0.args() }

fn on_manual(&self) -> Result<bool> {
    println!("Running manually!");
    self.0.on_manual()
}

fn on_update(&self, ops: &[PathOp]) -> Result<bool> {
    println!("Running manually {:?}", ops);
    self.0.on_update(ops)
}

} ```