use clap::{Parser, CommandFactory}; #[derive(Parser)] #[command(name = "picobot")] #[command(about = "A CLI chatbot", long_about = None)] enum Command { /// Connect to gateway Agent { /// Gateway WebSocket URL (e.g., ws://127.0.0.1:19876/ws) #[arg(long)] gateway_url: Option, }, /// Start gateway server Gateway { /// Host to bind to #[arg(long)] host: Option, /// Port to listen on #[arg(long)] port: Option, }, } #[tokio::main] async fn main() -> Result<(), Box> { let mut cmd = Command::command(); // If no arguments, print help if std::env::args().len() <= 1 { cmd.print_help()?; println!(); return Ok(()); } match Command::parse() { Command::Agent { gateway_url } => { let config = picobot::config::Config::load_default().ok(); let url = gateway_url .or_else(|| config.as_ref().map(|c| c.client.gateway_url.clone())) .unwrap_or_else(|| "ws://127.0.0.1:19876/ws".to_string()); picobot::client::run(&url).await?; } Command::Gateway { host, port } => { picobot::gateway::run(host, port).await?; } } Ok(()) }