Skip to content

introspect_cleo

Class info

🛈 DocStrings

Module for inspecting Cleo CLI applications.

get_info

get_info(instance: Application, command: str | None = None) -> CommandInfo

Return a CommandInfo object for command of given Cleo Application.

Parameters:

Name Type Description Default
instance Application

A Cleo Application instance

required
command str | None

The command to get info for (e.g. "cache clear").

None
Source code in src/clinspector/introspect/introspect_cleo.py
def get_info(instance: Application, command: str | None = None) -> commandinfo.CommandInfo:
    """Return a CommandInfo object for command of given Cleo Application.

    Args:
        instance: A Cleo Application instance
        command: The command to get info for (e.g. `"cache clear"`).
    """
    return resolve_command(parse(instance), command)

parse

parse(app: Application) -> CommandInfo

Parse a Cleo Application into a CommandInfo object.

Source code in src/clinspector/introspect/introspect_cleo.py
def parse(app: Application) -> commandinfo.CommandInfo:
    """Parse a Cleo Application into a CommandInfo object."""
    default_cmd_name = app._default_command  # usually "list"
    commands = app.all()  # also resolves lazily loaded commands
    sub_cmds = {
        n: _parse_command(cmd, name=n) for n, cmd in commands.items() if n != default_cmd_name
    }
    default_cmd = commands.get(default_cmd_name)
    return commandinfo.CommandInfo(
        name=app.name or "",
        description="",
        usage=f"{app.name} [options] [--] <command> [<arguments>]",
        subcommands=sub_cmds,
        params=_parse_command(default_cmd).params if default_cmd else [],
    )