zilliz 1.0.0

TUI and CLI tool for managing Zilliz Cloud clusters and Milvus operations
Documentation
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "zilliz",
    about = "CLI and TUI for Zilliz Cloud",
    version,
    disable_help_flag = true,
    disable_help_subcommand = true
)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Option<Commands>,

    /// Print help
    #[arg(long, short, global = true, action = clap::ArgAction::SetTrue)]
    pub help: bool,

    /// Output format: json, table, text, yaml, csv
    #[arg(long, short, global = true, default_value = "table")]
    pub output: Option<String>,

    /// JMESPath query to filter output
    #[arg(long, global = true)]
    pub query: Option<String>,

    /// Suppress table/CSV header row
    #[arg(long, global = true)]
    pub no_header: bool,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Configure API key and default settings
    #[command(hide = true, disable_help_subcommand = true)]
    Configure {
        #[command(subcommand)]
        subcmd: Option<ConfigureCommands>,
    },

    /// Manage current cluster context
    #[command(hide = true, disable_help_subcommand = true)]
    Context {
        #[command(subcommand)]
        subcmd: Option<ContextCommands>,
    },

    /// Show CLI version
    #[command(hide = true)]
    Version,

    /// Log in to Zilliz Cloud
    #[command(hide = true)]
    Login {
        /// Don't automatically open the browser
        #[arg(long)]
        no_browser: bool,

        /// Log in with API key (interactive prompt if no value given, or pass key directly)
        #[arg(long, num_args(0..=1), default_missing_value = "")]
        api_key: Option<String>,
    },

    /// Log out from Zilliz Cloud and clear stored credentials
    #[command(hide = true)]
    Logout,

    /// Authentication commands
    #[command(hide = true, disable_help_subcommand = true)]
    Auth {
        #[command(subcommand)]
        subcmd: Option<AuthCommands>,
    },

    /// Shell completion management
    #[command(hide = true, disable_help_subcommand = true)]
    Completion {
        #[command(subcommand)]
        subcmd: Option<CompletionCommands>,
    },

    /// Run a resource operation: zilliz <resource> <operation> [--flag value ...]
    #[command(external_subcommand)]
    External(Vec<String>),
}

#[derive(Subcommand)]
pub enum ContextCommands {
    /// Set the current cluster context
    Set {
        /// Cluster ID
        #[arg(long)]
        cluster_id: Option<String>,
        /// Cluster endpoint URL (auto-resolved from cluster-id if omitted)
        #[arg(long)]
        endpoint: Option<String>,
        /// Database name
        #[arg(long)]
        database: Option<String>,
    },
    /// Show the current context
    Current {
        /// Output format: json, table, text
        #[arg(long, short)]
        output: Option<String>,
    },
    /// Clear the current context
    Clear,
}

#[derive(Subcommand)]
pub enum ConfigureCommands {
    /// Set a configuration value
    Set {
        /// Configuration key (e.g. api_key, base_url)
        key: String,
        /// Value to set (omit for credential keys to enter securely via prompt)
        value: Option<String>,
    },
    /// Get a configuration value
    Get {
        /// Configuration key
        key: String,
    },
    /// List all configuration values
    List,
    /// Clear all stored credentials
    Clear,
}

#[derive(Subcommand)]
pub enum AuthCommands {
    /// Show current authentication status
    Status,
    /// Switch to a different organization
    Switch {
        /// Organization ID (interactive selection if omitted)
        org_id: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum CompletionCommands {
    /// Install shell completion to RC file
    Install {
        /// Shell type (auto-detected if omitted)
        #[arg(value_enum)]
        shell: Option<clap_complete::Shell>,
        /// Automatically write to shell RC file
        #[arg(long)]
        apply: bool,
    },
    /// Remove shell completion from RC file
    Uninstall {
        /// Shell type (auto-detected if omitted)
        #[arg(value_enum)]
        shell: Option<clap_complete::Shell>,
    },
    /// Check if shell completion is installed
    Status {
        /// Shell type (auto-detected if omitted)
        #[arg(value_enum)]
        shell: Option<clap_complete::Shell>,
    },
    /// Print completion script to stdout
    Show {
        /// Shell type
        #[arg(value_enum)]
        shell: clap_complete::Shell,
    },
}