Private
Public Access
1
0

kpcli: reorg subcommands

This commit is contained in:
2024-12-08 15:08:15 -08:00
parent 0e8b8f339a
commit 75d4767009
2 changed files with 24 additions and 19 deletions

View File

@@ -1,8 +1,6 @@
mod client_cli;
mod printers;
mod client;
use clap::{Parser, Subcommand};
use client_cli::ClientCli;
/// A command line interface for the Kordophone library and daemon
#[derive(Parser)]
@@ -17,26 +15,13 @@ enum Commands {
/// Commands for api client operations
Client {
#[command(subcommand)]
command: ClientCommands,
command: client::Commands,
},
}
#[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<dyn std::error::Error>> {
let mut client = ClientCli::new();
match command {
Commands::Client { command } => match command {
ClientCommands::Version => client.print_version().await,
ClientCommands::Conversations => client.print_conversations().await,
},
Commands::Client { command } => client::Commands::run(command).await,
}
}