2021-12-31 13:33:52 +01:00
|
|
|
use std::convert::Infallible;
|
2021-12-23 15:37:51 +01:00
|
|
|
|
|
|
|
use clap::ArgMatches;
|
|
|
|
use miette::Result;
|
2022-01-26 22:48:24 +01:00
|
|
|
use tracing::error;
|
|
|
|
use watchexec::{config::InitConfig, error::RuntimeError, handler::SyncFnHandler};
|
2021-12-23 15:37:51 +01:00
|
|
|
|
|
|
|
pub fn init(_args: &ArgMatches<'static>) -> Result<InitConfig> {
|
|
|
|
let mut config = InitConfig::default();
|
2022-01-10 08:47:06 +01:00
|
|
|
config.on_error(SyncFnHandler::from(
|
|
|
|
|data| -> std::result::Result<(), Infallible> {
|
2022-01-26 22:48:24 +01:00
|
|
|
if let RuntimeError::IoError {
|
|
|
|
about: "waiting on process group",
|
|
|
|
..
|
|
|
|
} = data
|
|
|
|
{
|
|
|
|
// "No child processes" and such
|
|
|
|
// these are often spurious, so condemn them to -v only
|
|
|
|
error!("{}", data);
|
|
|
|
return Ok(());
|
|
|
|
}
|
2021-12-31 13:33:52 +01:00
|
|
|
|
2022-01-10 08:47:06 +01:00
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
eprintln!("[[{:?}]]", data);
|
|
|
|
} else {
|
|
|
|
eprintln!("[[{}]]", data);
|
|
|
|
}
|
2021-12-31 13:33:52 +01:00
|
|
|
|
2022-01-10 08:47:06 +01:00
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
));
|
2021-12-31 13:33:52 +01:00
|
|
|
|
2021-12-23 15:37:51 +01:00
|
|
|
Ok(config)
|
|
|
|
}
|