kpcli: client: adds printing of conversations
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user