Plugin Command API#
BrokerServiceCommands helps conda plugins expose plugin-owned broker
commands such as conda my-plugin services start,
conda my-plugin services stop, and conda my-plugin services status.
The helper is intentionally scoped: plugin authors pass the broker service names that belong to their plugin, and generated positional service arguments are restricted to that set.
from conda_broker.plugin_commands import BrokerServiceCommands
broker_commands = BrokerServiceCommands(("conda-my-plugin.helper",))
Use conda_subcommand() when the plugin does not already have a conda
subcommand. Use add_group_to_subparsers() when the plugin has an existing
subcommand tree and needs a services subcommand inside it. Use
configure_commands_parser() when the plugin has already created a parser
that should contain direct broker service commands. add_commands_to_subparsers()
is a lower-level escape hatch for unusual argparse layouts.
Argparse helpers for plugin-owned broker service commands.
- class conda_broker.plugin_commands.BrokerServiceCommands(services: Sequence[str], *, source: str = '', commands: Sequence[str] = ('status', 'start', 'stop', 'restart', 'enable', 'disable', 'wait', 'logs'))[source]#
Install broker controls under another conda plugin’s subcommand parser.
The generated commands are scoped to the service names passed to the constructor. Positional service arguments use those names as argparse choices, and commands without explicit service arguments default to the same set. The default parser shape mounts broker controls under
services, producing commands likeconda my-plugin services status.- add_commands_to_subparsers(subcommands) None[source]#
Add direct broker commands to an existing subparser collection.
Prefer
configure_parser()oradd_group_to_subparsers()for the standardservicescommand group.
- add_group_to_subparsers(subcommands, *, name: str = 'services', help: str = 'Manage broker services.', description: str | None = None) ArgumentParser[source]#
Add broker commands under a named nested subcommand.
This is the collision-free form for plugins that already own names such as
statusorstart. For example, mounting the default group creates commands likeconda my-plugin services status.
- conda_subcommand(name: str, *, summary: str) CondaSubcommand[source]#
Return a
CondaSubcommandexposing this plugin’s service group.
- configure_commands_parser(parser: ArgumentParser) None[source]#
Configure a parser whose subcommands are direct broker commands.
- configure_parser(parser: ArgumentParser) None[source]#
Configure a parser with a
servicesbroker command group.
- execute(args: argparse.Namespace, *, console: Console | None = None) int[source]#
Execute a scoped broker service command.