2021-08-24 10:23:37 +02:00
|
|
|
use std::env::var;
|
2020-06-24 16:17:59 +02:00
|
|
|
|
2021-07-16 15:33:04 +02:00
|
|
|
use color_eyre::eyre::Result;
|
2021-08-24 10:23:37 +02:00
|
|
|
use tracing_subscriber::filter::LevelFilter;
|
2021-08-24 12:45:31 +02:00
|
|
|
use watchexec::{event::Event, Watchexec};
|
2021-05-10 12:44:35 +02:00
|
|
|
|
2021-04-10 15:33:40 +02:00
|
|
|
mod args;
|
2021-08-24 10:23:37 +02:00
|
|
|
mod config;
|
2016-09-14 15:30:59 +02:00
|
|
|
|
2021-08-24 10:23:37 +02:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
color_eyre::install()?;
|
2020-06-24 16:17:59 +02:00
|
|
|
|
2021-08-24 10:23:37 +02:00
|
|
|
if var("RUST_LOG").is_ok() {
|
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
}
|
2021-05-10 12:44:35 +02:00
|
|
|
|
2021-08-24 10:23:37 +02:00
|
|
|
let args = args::get_args()?;
|
|
|
|
|
|
|
|
if args.is_present("verbose") {
|
|
|
|
tracing_subscriber::fmt()
|
2021-08-24 12:45:31 +02:00
|
|
|
.with_max_level(match args.occurrences_of("verbose") {
|
|
|
|
0 => unreachable!(),
|
|
|
|
1 => LevelFilter::INFO,
|
|
|
|
2 => LevelFilter::DEBUG,
|
|
|
|
_ => LevelFilter::TRACE,
|
|
|
|
})
|
2021-08-24 10:23:37 +02:00
|
|
|
.try_init()
|
|
|
|
.ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
let (init, runtime) = config::new(&args)?;
|
|
|
|
|
|
|
|
let wx = Watchexec::new(init, runtime)?;
|
|
|
|
|
2021-08-24 12:45:31 +02:00
|
|
|
if !args.is_present("postpone") {
|
|
|
|
wx.send_event(Event::default()).await?;
|
|
|
|
}
|
|
|
|
|
2021-08-24 10:23:37 +02:00
|
|
|
wx.main().await??;
|
|
|
|
|
|
|
|
Ok(())
|
2020-06-24 16:17:59 +02:00
|
|
|
}
|