Private
Public Access
1
0
Files
Kordophone/kpcli/src/main.rs

54 lines
1.2 KiB
Rust
Raw Normal View History

mod client;
mod db;
mod printers;
2025-02-12 00:10:33 -08:00
mod daemon;
use anyhow::Result;
2024-11-09 17:35:39 -08:00
use clap::{Parser, Subcommand};
/// 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
},
/// Commands for the cache database
Db {
#[command(subcommand)]
command: db::Commands,
2025-02-12 00:10:33 -08:00
},
/// Commands for interacting with the daemon
Daemon {
#[command(subcommand)]
command: daemon::Commands,
}
2024-11-09 17:35:39 -08:00
}
async fn run_command(command: Commands) -> Result<()> {
match command {
2024-12-08 15:08:15 -08:00
Commands::Client { command } => client::Commands::run(command).await,
Commands::Db { command } => db::Commands::run(command).await,
2025-02-12 00:10:33 -08:00
Commands::Daemon { command } => daemon::Commands::run(command).await,
2024-11-09 17:35: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();
}