ghost-eye/src/main.rs

54 lines
1.2 KiB
Rust
Raw Normal View History

use clap::Parser;
use color_eyre::Result;
mod action;
mod app;
mod cli;
mod components;
mod config;
mod errors;
mod logging;
mod tui;
mod network;
mod widgets;
mod types;
mod palette;
#[tokio::main]
async fn start_tokio(
io_rx: std::sync::mpsc::Receiver<action::Action>,
network: &mut network::Network,
) {
while let Ok(io_event) = io_rx.recv() {
let _ = network.handle_network_event(io_event).await;
}
}
#[tokio::main]
async fn main() -> Result<()> {
crate::errors::init()?;
crate::logging::init()?;
let args = cli::Cli::parse();
let (sync_io_tx, sync_io_rx) = std::sync::mpsc::channel();
let (action_tx, action_rx) = tokio::sync::mpsc::unbounded_channel();
let cloned_action_tx = action_tx.clone();
std::thread::spawn(move || {
let mut network = network::Network::new(cloned_action_tx)
.with_url(&args.rpc_endpoint)
.with_timeout(args.timeout);
start_tokio(sync_io_rx, &mut network);
});
app::App::new(sync_io_tx, action_tx, action_rx)?
.with_frame_rate(args.frame_rate)
.with_tick_rate(args.tick_rate)
.with_mouse(args.mouse_needed)
.with_paste(args.paste_needed)
.run()
.await?;
Ok(())
}