Command API reference¶
dynamic_command ¶
dynamic_command = partial(command, cls=DynamicCommand)
A decorator wrapping click.command
that configures a DynamicCommand
. Example:
from __future__ import annotations
from typing import TYPE_CHECKING
from dda.cli.base import dynamic_command, pass_app
if TYPE_CHECKING:
from dda.cli.application import Application
@dynamic_command(short_help="Command")
@pass_app
def cmd(app: Application) -> None:
"""
Long description of the command.
"""
app.display("Running command")
dynamic_group ¶
dynamic_group = partial(group, cls=DynamicGroup)
A decorator wrapping click.group
that configures a DynamicGroup
. Example:
DynamicCommand ¶
DynamicCommand(
*args: Any,
features: list[str] | None = None,
dependencies: list[str] | None = None,
**kwargs: Any,
)
A subclass of the Command
class provided by rich-click that allows for dynamic help text and dependency management.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features | list[str] | None | A list of dependency groups that must be satisfied before the command callback can be invoked. These are defined in the | None |
dependencies | list[str] | None | An arbitrary list of dependencies that must be satisfied before the command callback can be invoked. | None |
Other Parameters:
Name | Type | Description |
---|---|---|
*args | Any | Additional positional arguments to pass to the |
**kwargs | Any | Additional keyword arguments to pass to the |
DynamicGroup ¶
DynamicGroup(
*args: Any,
allow_external_plugins: bool | None = None,
subcommand_filter: Callable[[str], bool] | None = None,
search_path_finder: Callable[[], list[str]] | None = None,
**kwargs: Any,
)
A subclass of the Group
class provided by rich-click that allows for dynamic loading of subcommands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_external_plugins | bool | None | Whether to allow external plugins to be loaded. The default is taken from the equivalent property of the parent group. | None |
subcommand_filter | Callable[[str], bool] | None | A function that takes a subcommand name and returns a boolean indicating whether the subcommand should be included in the list of subcommands. | None |
search_path_finder | Callable[[], list[str]] | None | A function that returns a list of directories to search for subcommands. | None |
Other Parameters:
Name | Type | Description |
---|---|---|
*args | Any | Additional positional arguments to pass to the |
**kwargs | Any | Additional keyword arguments to pass to the |