Commands
provide.foundation.hub.commands
¶
Command registration and management for the hub.
This module re-exports from the split modules for convenience.
Classes¶
CommandInfo
¶
Framework-agnostic command information.
Stores metadata about a registered command without framework-specific dependencies. The parameters field contains introspected parameter information that can be used by any CLI adapter.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Command name |
func |
Callable[..., Any]
|
Command function/callable |
description |
str | None
|
Command description (help text) |
aliases |
list[str]
|
Alternative names for the command |
hidden |
bool
|
Whether command is hidden from help |
category |
str | None
|
Command category for organization |
metadata |
dict[str, Any]
|
Additional custom metadata |
parent |
str | None
|
Parent command path (for nested commands) |
parameters |
list[ParameterInfo] | None
|
Introspected parameter information (lazy-loaded) |
Functions¶
create_command_group
¶
create_command_group(
name: str = "cli",
commands: list[str] | None = None,
registry: Any = None,
**kwargs: Any
) -> Any
Create command group (imports on first call to avoid circular import).
Source code in provide/foundation/hub/commands.py
get_command_registry
¶
register_command
¶
register_command(
name_or_func: str | F | None = None,
*,
description: str | None = None,
aliases: list[str] | None = None,
hidden: bool = False,
category: str | None = None,
group: bool = False,
replace: bool = False,
registry: Registry | None = None,
**metadata: Any
) -> Any
Register a CLI command in the hub.
Can be used as a decorator with or without arguments:
@register_command
def my_command():
pass
@register_command("custom-name", aliases=["cn"], category="utils")
def my_command():
pass
# Nested commands using dot notation - groups are auto-created
@register_command("container.status")
def container_status():
pass
@register_command("container.volumes.backup")
def container_volumes_backup():
pass
# Explicit group with custom description (optional)
@register_command("container", group=True, description="Container management")
def container_group():
pass
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name_or_func
|
str | F | None
|
Command name using dot notation for nesting (e.g., "container.status") |
None
|
description
|
str | None
|
Command description (defaults to docstring) |
None
|
aliases
|
list[str] | None
|
Alternative names for the command |
None
|
hidden
|
bool
|
Whether to hide from help listing |
False
|
category
|
str | None
|
Command category for grouping |
None
|
group
|
bool
|
Whether this is a command group (not a command) |
False
|
replace
|
bool
|
Whether to replace existing registration |
False
|
registry
|
Registry | None
|
Custom registry (defaults to global) |
None
|
**metadata
|
Any
|
Additional metadata stored in CommandInfo.metadata |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Decorator function or decorated function |
Source code in provide/foundation/hub/decorators.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |