onionwire/src/main.rs

25 lines
775 B
Rust
Raw Normal View History

use onionwire::tui::AppExit;
#[tokio::main]
async fn main() {
if let Err(e) = boot().await {
eprintln!("onionwire: {e}");
std::process::exit(1);
}
}
async fn boot() -> Result<(), String> {
let home = onionwire::Store::home_dir().map_err(|e| e.to_string())?;
eprintln!("onionwire: bootstrapping Arti…");
let node = onionwire::node::Node::start(home.clone()).await?;
let handle = tokio::runtime::Handle::current();
let exit = tokio::task::spawn_blocking(move || onionwire::tui::run(node, handle))
.await
.map_err(|e| e.to_string())??;
if exit == AppExit::WipeAll {
onionwire::Store::wipe_all(&home).map_err(|e| e.to_string())?;
eprintln!("onionwire: all local data wiped");
}
Ok(())
}