rusty_vault 0.2.1

RustyVault is a powerful identity-based secrets management software, providing features such as cryptographic key management, encryption as a service, public key cryptography, certificates management, identity credentials management and so forth. RustyVault's RESTful API is designed to be fully compatible with Hashicorp Vault.
Documentation
//! The `rusty_vault::cli` module is used to serve the RustyVault application.
//! This module basically accepts options from command-line and starts a server up.

use clap::{Parser, Subcommand};
use sysexits::ExitCode;

use crate::{VERSION, EXIT_CODE_INSUFFICIENT_PARAMS, cli::command::CommandExecutor};

pub mod command;
pub mod config;
pub mod util;

#[derive(Parser)]
#[command(
    version = VERSION,
    disable_help_subcommand = true,
    about = "A secure and high performance secret management software that is compatible with Hashicorp Vault."
)]
pub struct Cli {
    #[command(subcommand)]
    command: Option<Commands>,
}

#[derive(Subcommand)]
pub enum Commands {
    Server(command::server::Server),
    Status(command::status::Status),
    Operator(command::operator::Operator),
    Read(command::read::Read),
    Write(command::write::Write),
    Delete(command::delete::Delete),
    List(command::list::List),
    Login(command::login::Login),
    Auth(command::auth::Auth),
}

impl Commands {
    pub fn execute(&mut self) -> ExitCode {
        return match self {
            Commands::Server(server) => server.execute(),
            Commands::Status(status) => status.execute(),
            Commands::Operator(operator) => operator.execute(),
            Commands::Read(read) => read.execute(),
            Commands::Write(write) => write.execute(),
            Commands::Delete(delete) => delete.execute(),
            Commands::List(list) => list.execute(),
            Commands::Login(login) => login.execute(),
            Commands::Auth(auth) => auth.execute(),
        }
    }
}

impl Cli {
    /// Do real jobs.
    #[inline]
    pub fn run(&mut self) -> ExitCode {
        if let Some(ref mut cmd) = &mut self.command {
            return cmd.execute();
        }

        EXIT_CODE_INSUFFICIENT_PARAMS
    }
}