Skip to content

Subcommand requirements not being negated #4427

Answered by epage
marcaddeo asked this question in Q&A
Discussion options

You must be logged in to vote

That error isn't coming from clap's validation logic but the derive when it is trying to fill in the file field within the struct.

Options

  • Change the type to Option<String> and explicitly mark it as required.
  • Move all of the arguments into a GlobalArgs struct that you flatten with args: Option<GlobalArgs>
    • In the future, #2621 will make it so disjoint sets of arguments can be in an enum. We might be able to do the same with subcommands and implicitly set args_conflicts_with_subcommands

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@marcaddeo
Comment options

@explosion-mental
Comment options

Answer selected by marcaddeo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants