mirror of
https://github.com/CLIUtils/CLI11.git
synced 2026-01-19 04:52:08 +00:00
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:
@@ -132,7 +132,21 @@ gitbook:code $ ./my_program my_model_1 --model_flag --shared_flag
|
||||
```
|
||||
|
||||
Here, `--shared_flag` was set on the main app, and on the command line it "falls
|
||||
through" `my_model_1` to match on the main app.
|
||||
through" `my_model_1` to match on the main app. This is set through
|
||||
`->fallthrough()` on a subcommand.
|
||||
|
||||
#### Subcommand fallthrough
|
||||
|
||||
Subcommand fallthrough allows additional subcommands to be triggered after the
|
||||
first subcommand. By default subcommand fallthrough is enabled, but it can be
|
||||
turned off through `->subcommand_fallthrough(false)` on a subcommand. This will
|
||||
prevent additional subcommands at the same inheritance level from triggering,
|
||||
the strings would then be treated as positional values. As a technical note if
|
||||
fallthrough is enabled but subcommand fallthrough disabled (this is not the
|
||||
default in both cases), then subcommands on grandparents can still be triggered
|
||||
from the grandchild subcommand, unless subcommand fallthrough is also disabled
|
||||
on the parent. This is an unusual circumstance but may arise in some very
|
||||
particular situations.
|
||||
|
||||
### Prefix command
|
||||
|
||||
|
||||
Reference in New Issue
Block a user