mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-16 00:58:31 +01:00
71a178d4c2
With --on-update=do-nothing, we need to know when the process is done before we can spawn a new one, but we never actually used to truly check the process, only the presence or absence of a spawned process. That process may have already completed, but because we don't wait on it when in do-nothing mode, there is no opportunity to notice this. So now we either actually check the completion status of the process (on Windows), or we expose the `done` mutex value on demand (Unix). Essentially this adds a way to check the completion status of the process without blocking (modulo a mutex lock on unix). Fixes #200 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
Watchexec library
The library which powers Watchexec CLI and other tools.
- API documentation.
- Licensed under Apache 2.0.
- Minimum Supported Rust Version: 1.43.0.
Quick start
use watchexec::{
config::ConfigBuilder,
error::Result,
pathop::PathOp,
run::{
ExecHandler,
Handler,
watch,
},
};
fn main() -> Result<()> {
let config = ConfigBuilder::default()
.clear_screen(true)
.run_initially(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)
}
}