Subcommands#

The conda CLI can be extended with the conda_subcommands plugin hook. Registered subcommands will be available under the conda <subcommand> command.

class CondaSubcommand#

Return type to use when defining a conda subcommand plugin hook.

For details on how this is used, see conda_subcommands().

Parameters:
  • name -- Subcommand name (e.g., conda my-subcommand-name).

  • summary -- Subcommand summary, will be shown in conda --help.

  • action -- Callable that will be run when the subcommand is invoked.

  • configure_parser -- Callable that will be run when the subcommand parser is initialized.

action: collections.abc.Callable[[argparse.Namespace | tuple[str]], int | None]#
configure_parser: collections.abc.Callable[[argparse.ArgumentParser], None] | None = None#
name: str#

User-facing name of the plugin used for selecting & filtering plugins and error messages.

summary: str#
conda_subcommands() collections.abc.Iterable[conda.plugins.types.CondaSubcommand]#

Register external subcommands in conda.

Example:

from conda import plugins


def example_command(args):
    print("This is an example command!")


@plugins.hookimpl
def conda_subcommands():
    yield plugins.types.CondaSubcommand(
        name="example",
        summary="example command",
        action=example_command,
    )
Returns:

An iterable of subcommand entries.