54 lines
1.1 KiB
Rust
54 lines
1.1 KiB
Rust
mod client;
|
|
mod db;
|
|
mod printers;
|
|
mod daemon;
|
|
|
|
use anyhow::Result;
|
|
use clap::{Parser, Subcommand};
|
|
|
|
/// A command line interface for the Kordophone library and daemon
|
|
#[derive(Parser)]
|
|
#[command(name = "kpcli")]
|
|
struct Cli {
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// Commands for api client operations
|
|
Client {
|
|
#[command(subcommand)]
|
|
command: client::Commands,
|
|
},
|
|
|
|
/// Commands for the cache database
|
|
Db {
|
|
#[command(subcommand)]
|
|
command: db::Commands,
|
|
},
|
|
|
|
/// Commands for interacting with the daemon
|
|
Daemon {
|
|
#[command(subcommand)]
|
|
command: daemon::Commands,
|
|
}
|
|
}
|
|
|
|
async fn run_command(command: Commands) -> Result<()> {
|
|
match command {
|
|
Commands::Client { command } => client::Commands::run(command).await,
|
|
Commands::Db { command } => db::Commands::run(command).await,
|
|
Commands::Daemon { command } => daemon::Commands::run(command).await,
|
|
}
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let cli = Cli::parse();
|
|
|
|
run_command(cli.command).await
|
|
.map_err(|e| println!("Error: {}", e))
|
|
.err();
|
|
}
|