click_extra.config.subcommands module¶
Resolution of the reserved subcommand keys a configuration file can declare.
_default_subcommands and _prepend_subcommands are read from the loaded
configuration and turned into subcommand names, which
handle_parse_result() splices into
the residual arguments Click dispatches on.
Note
The keys are honored by whichever group carries the --config option, not only
by click-extra’s own Group. Injection happens at
parse time, from the option itself, because a plain click.Group offers
click-extra no other hook: a third-party framework building its group on
click.Group still gets the feature.
Caution
The option never sees two cases. Click prints the no_args_is_help screen of a
bare invocation before it processes any option, and a group reached through an
ancestor’s --config carries no option of its own. The first
ConfigOption a process builds puts
_group_parse_args() in place of click.Group.parse_args for the whole
process to cover both, whatever class the group is built on: see its
documentation.
- click_extra.config.subcommands.resolve_default_subcommands(ctx, group)[source]¶
Read and validate
_default_subcommandsfrom the loaded configuration.
- click_extra.config.subcommands.resolve_prepend_subcommands(ctx, group)[source]¶
Read and validate
_prepend_subcommandsfrom the loaded configuration.
- click_extra.config.subcommands.inject_reserved_subcommands(ctx, args)[source]¶
Return
argswith the reserved subcommand keys applied._default_subcommandsfills in for an invocation that names no subcommand. The command line always wins: whenargsalready carries one, the configured defaults are logged and dropped._prepend_subcommandsgoes in front of whatever remains, whether the subcommand came from the command line or from the defaults. It requires achain=Truegroup.Applies at most once per group, tracked in
SUBCOMMANDS_APPLIED. A group can be visited twice, by the pre-pass of a bare invocation and then by the regular parameter loop, and prepending the same subcommand on both passes would run it twice.- Raises:
click.UsageError – on an invalid value, an unknown subcommand, or a chain-mode violation.
- Return type: