mod server;
use server::ServerCommands;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(version, about, long_about)]
pub(crate) struct Cli {
#[arg(long, visible_alias = "url", env = "PDNS_WEBSERVER_URL")]
pub(crate) webserver_url: String,
#[arg(long, env = "PDNS_API_KEY")]
pub(crate) api_key: String,
#[command(subcommand)]
pub(crate) command: Commands,
}
#[derive(Debug, Subcommand)]
#[command(about, long_about)]
pub(crate) enum Commands {
Servers {
#[command(subcommand)]
command: ServerCommands,
},
}
impl Commands {
pub(crate) fn dispatch(
&self,
client: &pdns_client::Client,
) -> Result<(), Box<dyn std::error::Error>> {
match self {
Self::Servers { command } => {
command.dispatch(client)?;
}
}
Ok(())
}
}