Skip to content

Group --help options into sections for commands with shared signing/transaction options #2454

@leighmcculloch

Description

@leighmcculloch

What problem does your feature solve?

53 commands across the CLI list all options in a single flat Options: section, mixing command-specific parameters with shared signing, transaction, and source-account options. This makes it hard to quickly identify the core parameters of a command vs the shared boilerplate.

The affected command groups are:

  • All 22 stellar tx new subcommands
  • All 22 stellar tx operation add subcommands
  • 5 stellar contract subcommands (deploy, upload, extend, restore, invoke)
  • stellar contract asset deploy
  • stellar tx sign, stellar tx simulate, stellar message sign

For example, stellar tx new payment -h currently shows:

Options:
  -s, --source-account <SOURCE_ACCOUNT>   ...
      --sign-with-key <SIGN_WITH_KEY>     ...
      --hd-path <HD_PATH>                 ...
      --sign-with-lab                     ...
      --sign-with-ledger                  ...
      --fee <FEE>                         ...
      --inclusion-fee <INCLUSION_FEE>     ...
      --build-only                        ...
      --destination <DESTINATION>         ...
      --asset <ASSET>                     ...
      --amount <AMOUNT>                   ...
  -h, --help                              ...

The primary options (--destination, --asset, --amount) are buried among 8 shared options that appear identically on every tx new command.

What would you like to see?

Group the options into sections using clap's help_heading feature:

Options:
      --destination <DESTINATION>         Account to send to, e.g. `GBX...`
      --asset <ASSET>                     Asset to send, default native [default: native]
      --amount <AMOUNT>                   Amount of the asset to send, in stroops

Transaction Options:
  -s, --source-account <SOURCE_ACCOUNT>   Account that where transaction originates from...
      --fee <FEE>                         ⚠️ Deprecated, use `--inclusion-fee`...
      --inclusion-fee <INCLUSION_FEE>     Maximum fee amount for transaction inclusion...
      --build-only                        Build the transaction and only write the base64 xdr to stdout

Signing Options:
      --sign-with-key <SIGN_WITH_KEY>     Sign with a local key...
      --hd-path <HD_PATH>                 If using a seed phrase to sign...
      --sign-with-lab                     Sign with https://lab.stellar.org
      --sign-with-ledger                  Sign with a ledger wallet

Help Options:
  -h, --help                              Print help

Since the signing and transaction options come from shared structs, this can be fixed centrally by adding #[command(next_help_heading = "...")] or #[arg(help_heading = "...")] annotations in a few places, and all 53 commands benefit at once.

Relevant source files:

  • cmd/soroban-cli/src/config/mod.rsconfig::Args (source account, fee, inclusion fee)
  • cmd/soroban-cli/src/config/sign_with.rssign_with::Args (sign-with-key, hd-path, sign-with-lab, sign-with-ledger)
  • cmd/soroban-cli/src/commands/tx/args.rstx::Args (build-only, flattens config::Args)

What alternatives are there?

  • Keep the current flat list (status quo, but harder to scan)
  • Use subcommands instead of options for signing method (more disruptive change)

Links

Related internal discussion about this started at: https://stellarfoundation.slack.com/archives/C06KTGUULUF/p1773790328751939

❤️ Thanks for reporting @dmkozh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions