Skip to content

require on arg from a subcommand #3005

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

You must be logged in to vote

At the moment, no. Subcommands are scoped and we do not have a special syntax for accessing that scope.

We are talking about making clap's API more open ended with users being able to provide custom trait implementations for different parts of the process (lexing, parsing/validating a value, help generation, etc). We haven't started to map out what this would look like for the validation rules like requires but that might be a future possibility.

In the mean time, clap3 exposes an App::error function to allow users to do their own post-parse validation while creating an error message that looks like one from clap.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@epage
Comment options

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