pdns-cli 0.0.2

Rust client library and CLI for the PowerDNS Authoritative Server API
Documentation
//! # `pdns_cli`
//!
//! the `pdns_cli` binary crate provides a CLI for interacting with the `PowerDNS` Authoritative Server API.
//!
//! # Connecting to the API
//!
//! The CLI expects 2 parameters:
//!
//! 1) The webser url
//!
//! This url specifies the API endpoint to hit and can be specified in 2 ways
//! - `PDNS_WEBSERVER_URL` environment variable
//! - `webserver-url` cli parameter
//!
//! See [`pdns_client::Client::new`] for restrictions on the url
//!
//! 2) The webserver API key
//!
//! This is used for authenticating to the API (specified in the header of requests as `X-API-Key`) and can be specified in 2 ways
//! - `PDNS_API_KEY` environment variable
//! - `api-key` cli parameter
//!
//! # Examples
//!
//! ```bash
//! export PDNS_WEBSERVER_URL=http://127.0.0.1:8081/
//! export PDNS_API_KEY=changeme
//!
//! pdns-cli servers list
//! ```
//!
//!

// ////////////////////////////////////
// REGISTERING
// ////////////////////////////////////

mod cli;

// ////////////////////////////////////
//  USE: BRING INTO SCOPE
// ////////////////////////////////////

#[allow(clippy::wildcard_imports)]
use cli::*;

use clap::Parser;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args = Cli::parse();
    let client: pdns_client::Client = pdns_client::Client::new(args.webserver_url, &args.api_key)?;

    args.command.dispatch(&client)?;

    Ok(())
}