Private
Public Access
1
0

kpcli: client: adds printing of conversations

This commit is contained in:
2024-11-10 19:40:39 -08:00
parent 6b9f528cbf
commit 0e8b8f339a
9 changed files with 492 additions and 59 deletions

View File

@@ -1,9 +1,12 @@
use clap::{Parser, Subcommand};
use kordophone::APIInterface;
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")]
#[command(about = "CLI tool for the Kordophone daemon")]
struct Cli {
#[command(subcommand)]
command: Commands,
@@ -20,24 +23,28 @@ enum Commands {
#[derive(Subcommand)]
enum ClientCommands {
ListConversations,
/// Prints all known conversations on the server.
Conversations,
/// Prints the server Kordophone version.
Version,
}
fn main() {
let cli = Cli::parse();
match cli.command {
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::ListConversations => {
println!("Listing conversations...");
// TODO: Implement conversation listing
},
ClientCommands::Version => {
println!("Getting version...");
// TODO: Implement version getting
},
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();
}