mod client_cli; mod printers; use clap::{Parser, Subcommand}; use client_cli::ClientCli; /// A command line interface for the Kordophone library and daemon #[derive(Parser)] #[command(name = "kpcli")] struct Cli { #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Commands for api client operations Client { #[command(subcommand)] command: ClientCommands, }, } #[derive(Subcommand)] enum ClientCommands { /// Prints all known conversations on the server. Conversations, /// Prints the server Kordophone version. Version, } async fn run_command(command: Commands) -> Result<(), Box> { let mut client = ClientCli::new(); match command { Commands::Client { command } => match command { ClientCommands::Version => client.print_version().await, ClientCommands::Conversations => client.print_conversations().await, }, } } #[tokio::main] async fn main() { let cli = Cli::parse(); run_command(cli.command).await .map_err(|e| log::error!("Error: {}", e)) .err(); }