Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The old
required_subcommand
had several issues. This PR fixes those with a more thoughtful solution. The range of allowed subcommands can now be explicitly set, and CLI11 finally stops trying to match subcommands after the max number allowed is obtained. The changes:require_subcommand
now has a two-argument form, with min and max. Setting max to 0 means unlimited subcommands.RequiredError
if you have too many subcommands.-1
to set the default once. It only affects subcommands that have subcommands, obviously.I've left
.require_subcommand()
as setting 1 or more, though 1 might be better; I did that because 1 is intuitive for someone requiring 1 subcommand, and 1 or more is not obtainable with a single argument otherwise (and is rather undiscoverable as.require_subcommand(1,0)
).As part of the extended testing, I've reduced the "grabbyness" of the unlimited argument options. They now no longer eat up options if positionals remain (including unlimited positionals).