Command Groups¶
Use CommandGroup when you want to assemble a CLI tree explicitly instead of
letting Interfacy derive the full shape from a single callable or class.
CommandGroup¶
- class CommandGroup[source]¶
Bases:
objectA command group for building nested CLI hierarchies.
Supports manual construction of deeply nested command structures: - add_command(function) -> leaf command - add_command(class) -> subgroup with methods as commands - add_command(instance) -> subgroup with methods as commands (no __init__ args) - add_group(CommandGroup) -> nested subgroup
- add_command(
- command,
- name=None,
- description=None,
- aliases=None,
- pipe_targets=None,
- include_inherited_methods=None,
- include_protected_methods=None,
- include_private_methods=None,
- include_staticmethods=None,
- include_classmethods=None,
- method_skips=None,
- expand_model_params=None,
- model_expansion_max_depth=None,
- abbreviation_scope=None,
- help_option_sort=None,
- help_subcommand_sort=None,
- help_group=None,
- executable_flags=None,
Add a command to this group.
- Parameters:
command (Callable[..., Any] | type | Any) – Function, class, or class instance to add.
name (str | None) – Override the command name (defaults to function/class name).
description (str | None) – Override the description.
aliases (tuple[str, ...] | list[str] | None) – Alternative names for this command.
pipe_targets (PipeTargets | dict[str, Any] | Sequence[str] | str | None) – Configure stdin piping for this command.
include_inherited_methods (bool | None) – Override inherited-method inclusion.
include_protected_methods (bool | None) – Override protected-method inclusion.
include_private_methods (bool | None) – Override private-method inclusion.
include_staticmethods (bool | None) – Override staticmethod inclusion.
include_classmethods (bool | None) – Override classmethod inclusion.
method_skips (Sequence[str] | None) – Override class method skip list.
expand_model_params (bool | None) – Override model expansion toggle.
model_expansion_max_depth (int | None) – Override model expansion depth.
abbreviation_scope (AbbreviationScope | None) – Override abbreviation scope.
help_option_sort (list[HelpOptionSortRule] | None) – Override help option sort rules.
help_subcommand_sort (list[HelpSubcommandSortRule] | None) – Override help subcommand sort rules.
help_group (str | None) – Optional help-only group heading for this command in help listings.
executable_flags (list[ExecutableFlag] | None) – Zero-argument executable flags registered on this command node.
- add_group(
- group,
- name=None,
- help_group=None,
- executable_flags=None,
Add a nested subgroup.
- Parameters:
group (CommandGroup) – The CommandGroup to add as a subgroup.
name (str | None) – Override the subgroup name.
help_group (str | None) – Optional help-only group heading for this subgroup command.
executable_flags (list[ExecutableFlag] | None) – Zero-argument executable flags registered on the subgroup node.
- property commands: dict[str, CommandEntry]¶
Return a copy of the commands dictionary.
- property subgroups: dict[str, CommandGroup]¶
Return a copy of the subgroups dictionary.
- property subgroup_entries: dict[str, SubgroupEntry]¶
Return subgroup entries with associated metadata.