Codumentor logo Codumentor Enterprise

CLI Subcommands

A plugin can add a top-level codumentor <name> ... subcommand. This is not a
slash command. It runs in a fresh CLI process, before any
plugin host exists.

Contribute

Define a classmethod cli_group() on the plugin class. It returns a named
click.Group:

import click


class MyPlugin:
    @classmethod
    def cli_group(cls) -> click.Group:
        @click.group(name="myplugin", help="Manage my plugin's credential.")
        def group():
            pass

        @group.command("status")
        @click.pass_context
        def status(ctx):
            config = ctx.obj["config"]  # loaded by the root callback
            click.echo(f"instance home: {config.instance_home}")

        return group

The group then runs as codumentor [--config X] myplugin status.

When it is available

The command exists only while the plugin is configured and switched on in the
loaded config. The rule is the plugin loader's own: the merged plugins:
entries plus discovered external plugins. A plugin is off when it is in
disabled_plugins: or its entry has args.enabled: false.

Names