mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-14 08:11:11 +01:00
Add print_out example
This commit is contained in:
parent
f2f138ce9f
commit
ce60be2ec9
1 changed files with 30 additions and 0 deletions
30
lib/examples/print_out.rs
Normal file
30
lib/examples/print_out.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use tokio::time::sleep;
|
||||
use watchexec::{
|
||||
config::{InitConfigBuilder, RuntimeConfigBuilder},
|
||||
Watchexec,
|
||||
};
|
||||
|
||||
// Run with: `env RUST_LOG=debug cargo run --example print_out`
|
||||
#[tokio::main]
|
||||
async fn main() -> color_eyre::eyre::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
color_eyre::install()?;
|
||||
|
||||
let init = InitConfigBuilder::default()
|
||||
.error_handler(Box::new(|err| async move {
|
||||
eprintln!("Watchexec Runtime Error: {}", err);
|
||||
Ok::<(), std::convert::Infallible>(())
|
||||
}))
|
||||
.build()?;
|
||||
|
||||
let runtime = RuntimeConfigBuilder::default().build()?;
|
||||
|
||||
let wx = Watchexec::new(init, runtime)?;
|
||||
wx.main();
|
||||
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue