Skip to content

Document external subcommands #3887

@epage

Description

@epage

Discussed in #3863

Originally posted by cd-work June 22, 2022
I'd like to write an external subcommand that accepts any parameter and forwards it, however it should also still be documented as subcommand.

I think this is probably a pretty common scenario, since you usually have some way to know which external subcommands are available even if you do not know their exact parameters. I do not want to allow just any subcommand, I have a list which I want to accept with generic parameters, everything else should still cause a failure.

I've tried using ignore_errors(true), but that only seems to work globally and not on the subcommands themselves. Otherwise it could be used to just accept parameters.

I've also used various combinations of allowing hyphen values and multiple values, but none of them seem to allow for the first argument to have two hyphens.

I only care about the subcommands documentation and description on the toplevel, since bin subcommand --help should already be forwarded to the subcommand and not handled by clap. This is also a scenario where built-in subcommands and flags exist already, so it's not only external subcommands I'm worried about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helpArea: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsS-waiting-on-decisionStatus: Waiting on a go/no-go before implementing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions