mariadb-cli 0.1.1

One-shot agent-native command line client for MariaDB servers
Documentation
//! Stored configuration, written and read by this tool alone.
//!
//! Every key is written and read through a command here. No key is ever read
//! from the process environment, because a value that changes with the
//! surrounding shell is not a stored setting.

use clap::{Args, Subcommand};

/// The six configuration commands.
#[derive(Debug, Clone, Subcommand)]
pub enum ConfigCommand {
    /// Write the value of a key.
    Set(SetArgs),
    /// Read the value of a key.
    Get(KeyArgs),
    /// List the effective value and the origin of every key.
    List(ListArgs),
    /// Show where the configuration lives.
    Path,
    /// Remove a stored key and fall back to its default.
    Unset(KeyArgs),
    /// Point out an invalid key, an unreadable file or a wrong permission.
    Doctor,
}

/// Writing one key.
///
/// Both fields are optional to the argument layer and required to the command.
/// Publishing the contract must cost nothing, and a caller asking what this
/// command answers should not have to invent a key first. Absence is refused
/// where the write actually happens, and carries a code.
#[derive(Debug, Clone, Args)]
pub struct SetArgs {
    /// Key name.
    pub key: Option<String>,
    /// Value to store.
    pub value: Option<String>,
}

/// Addressing one key.
///
/// Optional to the argument layer and required to the command, for the reason
/// given on [`SetArgs`].
#[derive(Debug, Clone, Args)]
pub struct KeyArgs {
    /// Key name.
    pub key: Option<String>,
}

/// Listing the keys.
#[derive(Debug, Clone, Args)]
pub struct ListArgs {
    /// List only keys that carry a stored value.
    #[arg(long)]
    pub stored_only: bool,
}