Subcommand fallthrough (#1073)

Add modifier for subcommands to restrict subcommands falling through to
parent.
This will resolve #1022

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2024-10-09 04:46:45 -07:00
committed by GitHub
parent 79b1430019
commit ca66827263
8 changed files with 74 additions and 24 deletions

View File

@@ -905,10 +905,15 @@ option_groups. These are:
options are specified in the `add_option` calls or the ability to process
options in the form of `-s --long --file=file_name.ext`.
- `.fallthrough()`: Allow extra unmatched options and positionals to "fall
through" and be matched on a parent option. Subcommands always are allowed to
"fall through" as in they will first attempt to match on the current
through" and be matched on a parent option. Subcommands by default are allowed
to "fall through" as in they will first attempt to match on the current
subcommand and if they fail will progressively check parents for matching
subcommands.
subcommands. This can be disabled through `subcommand_fallthrough(false)` 🚧.
- `.subcommand_fallthrough()`: 🚧 Allow subcommands to "fall through" and be
matched on a parent option. Disabling this prevents additional subcommands at
the same level from being matched. It can be useful in certain circumstances
where there might be ambiguity between subcommands and positionals. The
default is true.
- `.configurable()`: Allow the subcommand to be triggered from a configuration
file. By default subcommand options in a configuration file do not trigger a
subcommand but will just update default values.