diff --git a/README.md b/README.md index 1c86b64..ba941a8 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,30 @@ directly from [crates.io](https://crates.io/crates/bdk-cli) with a command as be ```sh cargo install bdk-cli --features electrum ``` +## Command Aliases + +bdk-cli provides short aliases for commonly used commands to improve CLI ergonomics. + +### Top-level command aliases + +| Command | Alias | +|------------|-------| +| wallet | W | +| key | K | +| compile | C | +| repl | R | +| descriptor | D | + +### Wallet subcommand aliases + +| Command | Alias | +|---------------------|-------| +| new_address | new_addr | +| unused_address | unused_addr | +| create_tx | create | +| bump_fee | bump | +| public_descriptor | pub_desc | + ### bdk-cli bin usage examples diff --git a/src/commands.rs b/src/commands.rs index 7e65af2..ea4ffab 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -61,6 +61,7 @@ pub struct CliOpts { /// Top level cli sub-commands. #[derive(Debug, Subcommand, Clone, PartialEq)] #[command(rename_all = "snake")] + pub enum CliSubCommand { /// Wallet operations. /// @@ -68,6 +69,7 @@ pub enum CliSubCommand { /// Most commands can be used without connecting to any backend. To use commands that /// needs backend like `sync` and `broadcast`, compile the binary with specific backend feature /// and use the configuration options below to configure for that backend. + #[command(alias = "W")] Wallet { #[command(flatten)] wallet_opts: WalletOpts, @@ -81,13 +83,14 @@ pub enum CliSubCommand { /// /// These sub-commands are **EXPERIMENTAL** and should only be used for testing. Do not use this /// feature to create keys that secure actual funds on the Bitcoin mainnet. + #[command(alias = "K")] Key { #[clap(subcommand)] subcommand: KeySubCommand, }, /// Compile a miniscript policy to an output descriptor. #[cfg(feature = "compiler")] - #[clap(long_about = "Miniscript policy compiler")] + #[command(alias = "C", long_about = "Miniscript policy compiler")] Compile { /// Sets the spending policy to compile. #[arg(env = "POLICY", required = true, index = 1)] @@ -98,6 +101,7 @@ pub enum CliSubCommand { script_type: String, }, #[cfg(feature = "repl")] + #[command(alias = "R")] /// REPL command loop mode. /// /// REPL command loop can be used to make recurring callbacks to an already loaded wallet. @@ -110,6 +114,7 @@ pub enum CliSubCommand { /// /// Generate output descriptors from either extended key (Xprv/Xpub) or mnemonic phrase. /// This feature is intended for development and testing purposes only. + #[command(alias = "D")] Descriptor { /// Descriptor type (script type) #[arg( @@ -268,8 +273,10 @@ pub struct CompactFilterOpts { #[command(rename_all = "snake")] pub enum OfflineWalletSubCommand { /// Get a new external address. + #[command(alias = "new_addr")] NewAddress, /// Get the first unused external address. + #[command(alias = "unused_addr")] UnusedAddress, /// Lists the available spendable UTXOs. Unspent, @@ -278,6 +285,7 @@ pub enum OfflineWalletSubCommand { /// Returns the current wallet balance. Balance, /// Creates a new unsigned transaction. + #[command(alias = "create")] CreateTx { /// Adds a recipient to the transaction. // Clap Doesn't support complex vector parsing https://github.com/clap-rs/clap/issues/1704. @@ -326,6 +334,7 @@ pub enum OfflineWalletSubCommand { add_data: Option, //base 64 econding }, /// Bumps the fees of an RBF transaction. + #[command(alias = "bump")] BumpFee { /// TXID of the transaction to update. #[arg(env = "TXID", long = "txid")] @@ -354,6 +363,7 @@ pub enum OfflineWalletSubCommand { /// Returns the available spending policies for the descriptor. Policies, /// Returns the public version of the wallet's descriptor(s). + #[command(alias = "pub_desc")] PublicDescriptor, /// Signs and tries to finalize a PSBT. Sign {