2025-01-08 13:32:55 -08:00
|
|
|
mod client;
|
|
|
|
|
mod db;
|
2024-11-10 19:40:39 -08:00
|
|
|
mod printers;
|
2025-01-08 13:32:55 -08:00
|
|
|
|
|
|
|
|
use anyhow::Result;
|
2024-11-09 17:35:39 -08:00
|
|
|
use clap::{Parser, Subcommand};
|
|
|
|
|
|
2024-11-10 19:40:39 -08:00
|
|
|
/// A command line interface for the Kordophone library and daemon
|
2024-11-09 17:35:39 -08:00
|
|
|
#[derive(Parser)]
|
|
|
|
|
#[command(name = "kpcli")]
|
|
|
|
|
struct Cli {
|
|
|
|
|
#[command(subcommand)]
|
|
|
|
|
command: Commands,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Subcommand)]
|
|
|
|
|
enum Commands {
|
|
|
|
|
/// Commands for api client operations
|
|
|
|
|
Client {
|
|
|
|
|
#[command(subcommand)]
|
2024-12-08 15:08:15 -08:00
|
|
|
command: client::Commands,
|
2024-11-09 17:35:39 -08:00
|
|
|
},
|
2025-01-08 13:32:55 -08:00
|
|
|
|
|
|
|
|
/// Commands for the cache database
|
|
|
|
|
Db {
|
|
|
|
|
#[command(subcommand)]
|
|
|
|
|
command: db::Commands,
|
|
|
|
|
}
|
2024-11-09 17:35:39 -08:00
|
|
|
}
|
|
|
|
|
|
2025-01-08 13:32:55 -08:00
|
|
|
async fn run_command(command: Commands) -> Result<()> {
|
2024-11-10 19:40:39 -08:00
|
|
|
match command {
|
2024-12-08 15:08:15 -08:00
|
|
|
Commands::Client { command } => client::Commands::run(command).await,
|
2025-01-08 13:32:55 -08:00
|
|
|
Commands::Db { command } => db::Commands::run(command).await,
|
2024-11-09 17:35:39 -08:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-10 19:40:39 -08:00
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() {
|
|
|
|
|
let cli = Cli::parse();
|
|
|
|
|
|
|
|
|
|
run_command(cli.command).await
|
|
|
|
|
.map_err(|e| log::error!("Error: {}", e))
|
|
|
|
|
.err();
|
|
|
|
|
}
|