mod cli;
use anyhow::Result;
use clap::Parser;
fn main() -> Result<()> {
let cli = cli::Cli::parse();
let (done_tx, done_rx) = std::sync::mpsc::channel::<Result<()>>();
std::thread::spawn(move || {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to build tokio runtime");
let result = rt.block_on(cli.run());
let _ = done_tx.send(result);
unsafe {
core_foundation::runloop::CFRunLoopStop(core_foundation::runloop::CFRunLoopGetMain());
}
});
loop {
unsafe {
core_foundation::runloop::CFRunLoopRunInMode(
core_foundation::runloop::kCFRunLoopDefaultMode,
0.1,
false as u8,
);
}
if let Ok(result) = done_rx.try_recv() {
return result;
}
}
}