Index
provide.foundation.cli.click
¶
Click CLI framework adapter.
Provides Click-specific implementation of the CLIAdapter protocol.
Classes¶
ClickAdapter
¶
Click framework adapter.
Implements the CLIAdapter protocol for the Click framework, converting framework-agnostic CommandInfo objects to Click commands and groups.
Examples:
>>> adapter = ClickAdapter()
>>> command = adapter.build_command(command_info)
>>> isinstance(command, click.Command)
True
Functions¶
build_command
¶
Build Click command from CommandInfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
CommandInfo
|
Framework-agnostic command information |
required |
Returns:
| Type | Description |
|---|---|
Command
|
Click Command object |
Raises:
| Type | Description |
|---|---|
CLIBuildError
|
If command building fails |
Source code in provide/foundation/cli/click/adapter.py
build_group
¶
build_group(
name: str,
commands: list[CommandInfo] | None = None,
registry: Registry | None = None,
**kwargs: Any
) -> click_types.Group
Build Click group with commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Group name |
required |
commands
|
list[CommandInfo] | None
|
List of CommandInfo objects (or None to use registry) |
None
|
registry
|
Registry | None
|
Command registry |
None
|
**kwargs
|
Any
|
Additional Click Group options |
{}
|
Returns:
| Type | Description |
|---|---|
Group
|
Click Group object |
Raises:
| Type | Description |
|---|---|
CLIBuildError
|
If group building fails |
Source code in provide/foundation/cli/click/adapter.py
Functions¶
create_command_group
¶
create_command_group(
name: str = "cli",
commands: list[str] | None = None,
registry: Registry | None = None,
**kwargs: Any
) -> Group
Create a Click group with registered commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for the CLI group |
'cli'
|
commands
|
list[str] | None
|
List of command names to include (None = all) |
None
|
registry
|
Registry | None
|
Custom registry (defaults to global) |
None
|
**kwargs
|
Any
|
Additional Click Group options |
{}
|
Returns:
| Type | Description |
|---|---|
Group
|
Click Group with registered commands |
Raises:
| Type | Description |
|---|---|
CLIBuildError
|
If group creation fails |
Example
Register some commands¶
@register_command("init") def init_cmd(): pass
Create CLI group¶
cli = create_command_group("myapp")
Run the CLI¶
if name == "main": cli()
Source code in provide/foundation/cli/click/builder.py
ensure_parent_groups
¶
Ensure all parent groups in the path exist, creating them if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_path
|
str
|
Dot-notation path (e.g., "db.migrate") |
required |
registry
|
Registry
|
Command registry to update |
required |