use clap::Parser;
use ghost_client_cli::{KeySubcommand, VanityCmd};

#[derive(Debug, Parser)]
#[command(name = "ghostkey", author = "f4t50", about = "Ghost Key Tool", version)]
pub enum Ghostkey {
    /// Key utility for the CLI
    #[clap(flatten)]
    KeyCli(KeySubcommand),

    /// Sign a message, with a given (secret) key.
    Sign(sc_cli::SignCmd),

    /// Generate a seed that provides a vanity address/
    Vanity(VanityCmd),

    /// Verify a signature for a mesage, provided on STDIN, with a given
    /// (public or secret) key.
    Verify(sc_cli::VerifyCmd),
}

/// Run the ghostkey command, given the appropriate runtime.
pub fn run() -> Result<(), sc_cli::Error> {
    match Ghostkey::parse() {
        Ghostkey::KeyCli(cmd) => cmd.run(cli),
        Ghostkey::Sign(cmd) => cmd.run(),
        Ghostkey::Vanity(cmd) => cmd.run(),
        Ghostkey::Verify(cmd) => cmd.run(),
    }
}
