2021-08-21 11:12:40 +02:00
|
|
|
use std::time::Duration;
|
|
|
|
|
2021-10-10 10:04:40 +02:00
|
|
|
use miette::Result;
|
2021-08-21 11:12:40 +02:00
|
|
|
use tokio::time::sleep;
|
|
|
|
use watchexec::{
|
2021-08-24 09:59:11 +02:00
|
|
|
config::{InitConfig, RuntimeConfig},
|
2021-08-21 11:12:40 +02:00
|
|
|
Watchexec,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[tokio::main]
|
2021-10-10 10:04:40 +02:00
|
|
|
async fn main() -> Result<()> {
|
2021-08-21 11:12:40 +02:00
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
|
2021-10-09 07:37:13 +02:00
|
|
|
let mut init = InitConfig::default();
|
2021-08-22 12:05:09 +02:00
|
|
|
init.on_error(|err| async move {
|
|
|
|
eprintln!("Watchexec Runtime Error: {}", err);
|
|
|
|
Ok::<(), std::convert::Infallible>(())
|
|
|
|
});
|
2021-08-21 11:12:40 +02:00
|
|
|
|
2021-08-22 10:49:24 +02:00
|
|
|
let runtime = RuntimeConfig::default();
|
2021-08-21 11:12:40 +02:00
|
|
|
|
2021-10-09 07:37:13 +02:00
|
|
|
let wx = Watchexec::new(init, runtime)?;
|
2021-08-21 11:12:40 +02:00
|
|
|
wx.main();
|
|
|
|
|
|
|
|
// TODO: induce an error here
|
|
|
|
|
|
|
|
sleep(Duration::from_secs(1)).await;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|