Skip to content

Clean up CLI commands and options #1274

@onbjerg

Description

@onbjerg

The output of cast help/forge help and -h/--help is, in some cases, very large and not super helpful. I attempted to address some of it in #1268, but there are still improvements we can make:

Remove opts that are not used by commands

We should try to split the opts structs more, so we only pull in what we need.

  • forge run
    • Does not use the following from BuildArgs:
      • -d/--delay
      • --extra-output
      • --extra-output-files
      • --force
      • --ignored-error-codes
      • --names
      • --no-restart
      • -o/--out
      • --run-all
      • --sizes
      • -w/--watch
      • -c/--contracts(?)
      • --cache-path(?)
  • forge tree
    • Does not use the following from BuildArgs:
      • -d/--delay
      • --evm-version
      • --extra-output
      • --extra-output-files
      • --force
      • --ignored-error-codes
      • --libraries
      • --names
      • --no-auto-detect
      • --no-restart
      • -o/--out
      • --offline
      • --optimize
      • --optimize-runs
      • --run-all
      • --sizes
      • --use
      • --via-ir
      • -w/--watch
  • forge config
    • I'm not sure why there are so many options in this command (cc @mattsse)
  • forge create
    • Does not use the following from BuildArgs:
      • -d/--delay
      • --evm-version
      • --extra-output
      • --extra-output-files
      • --ignored-error-codes
      • --names
      • --no-restart
      • --run-all
      • --sizes
      • --use
      • -w/--watch
  • forge test
    • Does not use the following from BuildArgs:
      • --extra-output
      • --extra-output-files
      • --names (it can, but should it?)
      • --sizes (it can, but should it?)
  • cast estimate
    • Does not use the following from EthereumOpts:
      • Any of the Wallet options
  • cast access-list
    • Only uses --etherscan-api-key and --chain from EthereumOpts

Use next_help_heading

We should use next_help_heading to logically group options. Since options are alphabetically sorted, some options you care about more (i.e. options for the specific command) might be placed next to options that you may not care about as much.

As an example, for forge tree, --no-dedupe is next to --no-restart and --names (two options we do not care about at all in this case).

Merge commands with common functionality

  • forge test --gas-report and forge snapshot serve somewhat similar purposes. I know we've talked about potentially merging these, so I'm including it here.
  • cast --calldata-decode and cast 4byte-decode could be merged into cast --calldata-decode --4byte or similar
  • cast --to-wei and cast --to-unit should be merged since the default behavior for cast --to-unit is exactly what cast --to-wei is doing
  • cast --concat-hex duplicates functionality in cast --to-hexdata
  • cast wallet vanity could be merged into cast wallet new --vanity

These lists are non-exhaustive - I haven't checked everything

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-castCommand: castC-forgeCommand: forgeD-choreDifficulty: choreP-normalPriority: normal

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions