pub mod commands; pub mod config; pub mod error; pub mod shell; use clap::{Parser, Subcommand}; #[derive(Parser)] #[command(name = "crypto-cli")] #[command(about = "Cryptographic operations CLI with Rhai scripting support", long_about = None)] pub struct Cli { #[command(subcommand)] pub command: Commands, #[arg(short, long, help = "Enable verbose output")] pub verbose: bool, #[arg(short, long, help = "Config file path")] pub config: Option, } #[derive(Subcommand)] pub enum Commands { /// Key management commands Key { #[command(subcommand)] command: KeyCommands, }, /// Encryption/decryption commands Crypto { #[command(subcommand)] command: CryptoCommands, }, /// Ethereum wallet commands Ethereum { #[command(subcommand)] command: EthereumCommands, }, /// Execute Rhai script Script { #[arg(help = "Path to Rhai script file")] path: Option, #[arg(short, long, help = "Execute script from string")] inline: Option, }, /// Interactive shell Shell, } // Define subcommands for each category #[derive(Subcommand)] pub enum KeyCommands { /// Create a new key space CreateSpace { /// Name of the key space name: String, #[arg(long)] /// Password to encrypt the key space (required) password: String }, /// List available key spaces ListSpaces, /// Load a key space Load { /// Name of the key space to load name: String, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Create a new keypair in the current key space CreateKeypair { /// Name of the keypair name: String, #[arg(long)] space: Option, #[arg(long)] password: Option }, /// List keypairs in the current key space ListKeypairs { #[arg(long)] /// Key space to list keypairs from space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Export a keypair Export { /// Name of the keypair to export name: String, /// Output file path (prints to stdout if not specified) output: Option, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Import a keypair Import { /// Name to give the imported keypair name: String, /// Input file path (reads from stdin if not specified) input: Option, #[arg(long)] /// Key space to import the keypair into space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, } #[derive(Subcommand)] pub enum CryptoCommands { /// Sign a message with a keypair Sign { #[arg(long)] /// Message to sign (as a string) message: Option, #[arg(long)] /// Input file containing the message to sign input: Option, #[arg(long)] /// Name of the keypair to use for signing keypair: String, #[arg(long)] /// Output file for the signature (prints to stdout if not specified) output: Option, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Verify a signature Verify { #[arg(long)] /// Message to verify (as a string) message: Option, #[arg(long)] /// Input file containing the message to verify input: Option, #[arg(long)] /// Signature to verify (base64 encoded) signature: String, #[arg(long)] /// Name of the keypair to use for verification keypair: Option, #[arg(long)] /// Public key to use for verification (base64 encoded) pubkey: Option, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Encrypt data for a recipient Encrypt { #[arg(long)] /// Data to encrypt (as a string) data: Option, #[arg(long)] /// Input file containing the data to encrypt input: Option, #[arg(long)] /// Name of the recipient keypair recipient: String, #[arg(long)] /// Output file for the encrypted data (prints to stdout if not specified) output: Option, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Decrypt data with a keypair Decrypt { #[arg(long)] /// Data to decrypt (as a string, base64 encoded) data: Option, #[arg(long)] /// Input file containing the data to decrypt input: Option, #[arg(long)] /// Name of the keypair to use for decryption keypair: String, #[arg(long)] /// Output file for the decrypted data (prints to stdout if not specified) output: Option, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, } #[derive(Subcommand)] pub enum EthereumCommands { /// Create an Ethereum wallet from a keypair Create { #[arg(long)] /// Name of the keypair to use keypair: String, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Get the Ethereum address for a keypair Address { #[arg(long)] /// Name of the keypair keypair: String, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, /// Get the balance of an Ethereum address Balance { #[arg(long)] /// Ethereum address (uses the current wallet if not specified) address: Option, #[arg(long)] /// Network to use (e.g., "gnosis") network: String, #[arg(long)] /// Key space containing the keypair space: Option, #[arg(long)] /// Password to decrypt the key space password: Option }, }