mariadb-cli 0.1.1

One-shot agent-native command line client for MariaDB servers
Documentation
//! What each published command actually does.

pub mod config;
pub mod conn;
pub mod contract;
pub mod data;
pub mod history;
pub mod input;
pub mod meta;
pub mod query;
pub mod query_change;
pub mod query_read;
pub mod schema;
pub mod server;

use crate::cli::Command;
use crate::error::Failure;

/// Every leaf command this build actually serves, written in full.
///
/// The list names whole leaves rather than family prefixes, because a prefix
/// answers for commands it was never asked about: a leaf added under a served
/// family would claim to work before anything routed it. A test holds this
/// list and the tree `clap` publishes to the same length and the same names,
/// so the state reported to a caller can never drift from what runs.
///
/// # Why sixty-three here and sixty in the published map
///
/// The command map publishes `query named` as one command, because a caller
/// reads it as one thing that saves and runs a named query. The tree `clap`
/// carries splits it into its four actions, which are four leaves. So the same
/// surface is sixty commands to a reader and sixty-three leaves to the
/// router, and the difference is exactly those three extra actions. Both counts
/// are held by tests, so neither can move on its own.
pub const SERVED_LEAVES: [&str; 63] = [
    "config doctor",
    "config get",
    "config list",
    "config path",
    "config set",
    "config unset",
    "conn add",
    "conn default",
    "conn edit",
    "conn list",
    "conn remove",
    "conn show",
    "conn test",
    "data export",
    "data import",
    "history as-of",
    "history between",
    "history tables",
    "meta commands",
    "meta completions",
    "meta manual",
    "meta schema",
    "meta version",
    "query analyze",
    "query call",
    "query explain",
    "query file",
    "query lineage",
    "query named list",
    "query named remove",
    "query named run",
    "query named save",
    "query plan",
    "query run",
    "query sample",
    "query tx",
    "schema columns",
    "schema checks",
    "schema count",
    "schema databases",
    "schema ddl",
    "schema events",
    "schema grants",
    "schema indexes",
    "schema keys",
    "schema map",
    "schema partitions",
    "schema routines",
    "schema search",
    "schema sequences",
    "schema size",
    "schema stats",
    "schema tables",
    "schema triggers",
    "schema views",
    "server capabilities",
    "server kill",
    "server locks",
    "server processes",
    "server queries",
    "server replica",
    "server status",
    "server variables",
];

/// The failure a published but unserved command answers with.
///
/// The command stays on the surface, so the tree never differs between builds,
/// and the caller is told plainly that this build does not serve it yet.
#[must_use]
pub fn not_yet_served(command: &Command) -> Failure {
    Failure::usage(
        "usage.not_yet_served",
        format!(
            "`{}` is published but not served by this build",
            command.published_name()
        ),
    )
    .with_detail("detail", command.published_name())
    .with_hint("run `meta commands` to see which commands this build serves")
}