Classes
GroupDef
6
▼
Frozen snapshot of a command group.
GroupDef
6
▼
Frozen snapshot of a command group.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
description |
str
|
— |
commands |
dict[str, Any]
|
— |
groups |
dict[str, GroupDef]
|
— |
aliases |
tuple[str, ...]
|
— |
hidden |
bool
|
— |
Group
11
▼
A nestable command namespace.
Usage::
site = cli.group("site", description="Site operations")…
Group
11
▼
A nestable command namespace.
Usage::
site = cli.group("site", description="Site operations")
@site.command("build", description="Build the site")
def build(output: str = "_site") -> str: ...
config = site.group("config", description="Config management")
@config.command("show", description="Show merged config")
def show() -> dict: ...
CLI::
myapp site build --output _site
myapp site config show
Methods
commands
0
dict[str, Any]
▼
All registered commands in this group.
property
commands
0
dict[str, Any]
▼
def commands(self) -> dict[str, Any]
Returns
dict[str, Any]
groups
0
dict[str, Group]
▼
All registered sub-groups.
property
groups
0
dict[str, Group]
▼
def groups(self) -> dict[str, Group]
Returns
dict[str, Group]
command
7
Callable
▼
Register a function as a command within this group.
command
7
Callable
▼
def command(self, name: str, *, description: str = '', aliases: tuple[str, ...] | list[str] = (), tags: tuple[str, ...] | list[str] = (), hidden: bool = False, examples: tuple[dict[str, Any], ...] | list[dict[str, Any]] = (), confirm: str = '') -> Callable
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
description |
— |
Default:''
|
aliases |
— |
Default:()
|
tags |
— |
Default:()
|
hidden |
— |
Default:False
|
examples |
— |
Default:()
|
confirm |
— |
Default:''
|
Returns
Callable
lazy_command
7
Any
▼
Register a lazy-loaded command within this group.
The handler module is not im…
lazy_command
7
Any
▼
def lazy_command(self, name: str, import_path: str, *, description: str = '', schema: dict[str, Any] | None = None, aliases: tuple[str, ...] | list[str] = (), tags: tuple[str, ...] | list[str] = (), hidden: bool = False) -> Any
Register a lazy-loaded command within this group.
The handler module is not imported until the command is invoked.
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
import_path |
— |
|
description |
— |
Default:''
|
schema |
— |
Default:None
|
aliases |
— |
Default:()
|
tags |
— |
Default:()
|
hidden |
— |
Default:False
|
Returns
Any
group
4
Group
▼
Create and register a sub-group. Returns it for chaining.
group
4
Group
▼
def group(self, name: str, *, description: str = '', aliases: tuple[str, ...] | list[str] = (), hidden: bool = False) -> Group
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
description |
— |
Default:''
|
aliases |
— |
Default:()
|
hidden |
— |
Default:False
|
Returns
Group
add_group
1
▼
Add an existing Group as a sub-group.
add_group
1
▼
def add_group(self, group: Group) -> None
Parameters
| Name | Type | Description |
|---|---|---|
group |
— |
get_command
1
Any | None
▼
Look up a command by name or alias within this group.
get_command
1
Any | None
▼
def get_command(self, name: str) -> Any | None
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Returns
Any | None
get_group
1
Group | None
▼
Look up a sub-group by name or alias.
get_group
1
Group | None
▼
def get_group(self, name: str) -> Group | None
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Returns
Group | None
to_def
0
GroupDef
▼
Freeze into immutable GroupDef tree.
to_def
0
GroupDef
▼
def to_def(self) -> GroupDef
Returns
GroupDef
walk_commands
1
▼
Yield (dotted_path, CommandDef) for all commands in this tree.
walk_commands
1
▼
def walk_commands(self, prefix: str = '')
Parameters
| Name | Type | Description |
|---|---|---|
prefix |
— |
Default:''
|
Internal Methods 1 ▼
__init__
4
▼
__init__
4
▼
def __init__(self, name: str, *, description: str = '', aliases: tuple[str, ...] | list[str] = (), hidden: bool = False) -> None
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
description |
— |
Default:''
|
aliases |
— |
Default:()
|
hidden |
— |
Default:False
|