Ability to customize the built-in help
subcommand
#5815
Labels
A-builder
Area: Builder API
C-enhancement
Category: Raise on the bar on expectations
S-waiting-on-design
Status: Waiting on user-facing design to be resolved before implementing
Please complete the following tasks
Clap Version
4.5.20
Describe your use case
It's currently fairly cumbersome to alter the
about
message for auto-generated help subcommands when usingclap-derive
. Consider the following example scenario:To use the parser as-is, we can run something like:
But if we'd like to customize the
about
message for the generated help subcommand, we can no longer use the niceparse
methods onCli
, and instead need to do something like:And for the sake of completeness, if we now run this with
cargo run -- help
, we'd get:Describe the solution you'd like
One way to streamline this would be to provide a
build()
method onCommand
which returnsself
, so that we can directly callmut_subcommand
in the#[command()]
macro. For example, ifCommand
had something like:Then we could do the following:
Note that trying to use
build()
in place of thebuild_for_derive()
above doesn't work, asbuild()
mutates theCommand
in-place and doesn't return anything, which breaks theParser
derive macro.Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: