use anyhow::Result; use clap::Parser; use tracing_subscriber::EnvFilter; mod app; mod client; mod event; mod input; mod ui; /// Pinakes terminal UI client #[derive(Parser)] #[command(name = "pinakes-tui", version, about)] struct Cli { /// Server URL to connect to #[arg( short, long, env = "PINAKES_SERVER_URL", default_value = "http://localhost:3000" )] server: String, /// Set log level (trace, debug, info, warn, error) #[arg(long, default_value = "warn")] log_level: String, /// Log to file instead of stderr (avoids corrupting TUI display) #[arg(long)] log_file: Option, } #[tokio::main] async fn main() -> Result<()> { let cli = Cli::parse(); // Initialize logging - for TUI, must log to file to avoid corrupting the display let env_filter = EnvFilter::try_new(&cli.log_level).unwrap_or_else(|_| EnvFilter::new("warn")); if let Some(log_path) = &cli.log_file { let file = std::fs::File::create(log_path)?; tracing_subscriber::fmt() .with_env_filter(env_filter) .with_writer(file) .with_ansi(false) .init(); } else { // When no log file specified, suppress all output to avoid TUI corruption tracing_subscriber::fmt() .with_env_filter(EnvFilter::new("off")) .init(); } app::run(&cli.server).await }