Skip to content

types

CliCommands dataclass

Container to store the commands and subcommands for the cli.

Source code in m/cli/engine/types.py
@dataclass
class CliCommands:
    """Container to store the commands and subcommands for the cli."""

    commands: dict[str, CommandModule | CliSubcommands]

    # Optional root meta data to provide information about the cli.
    meta: MetaModule | None

CliSubcommands dataclass

Container to store subcommands.

Source code in m/cli/engine/types.py
@dataclass
class CliSubcommands:
    """Container to store subcommands."""

    # Dictionary of subcommands.
    subcommands: CommandModuleMap

    # Each subcommand needs to provide metadata to create the help message.
    meta: MetaModule | None

CommandInputs dataclass

Inputs to command decorator.

Source code in m/cli/engine/types.py
@dataclass
class CommandInputs:
    """Inputs to command decorator."""

    help: str

    model: type[BaseModel]

CommandModule dataclass

Container to store the run function from a "command" module.

Source code in m/cli/engine/types.py
@dataclass
class CommandModule:
    """Container to store the run function from a "command" module."""

    run: DecoratedRunFunction

FuncArgs dataclass

Stores function arguments.

Source code in m/cli/engine/types.py
@dataclass
class FuncArgs:
    """Stores function arguments."""

    args: list[Any]
    kwargs: dict[str, Any]

MetaModule dataclass

Container to store a metadata dictionary from a "meta" module.

Source code in m/cli/engine/types.py
@dataclass
class MetaModule:
    """Container to store a metadata dictionary from a "meta" module."""

    meta: dict[str, str]
    add_arguments: Callable[[ap.ArgumentParser], None] | None = None

add_arg(*args, **kwargs)

Wrap FuncArgs arguments in a function.

Parameters:

Name Type Description Default
args Any

The arguments to argparse add_arguments.

()
kwargs Any

The keyword arguments to argparse add arguments.

{}

Returns:

Type Description
FuncArgs

A FuncArgs instance.

Source code in m/cli/engine/types.py
@typing_extensions.deprecated(
    'The `add_arg` method is deprecated; use `m.cli.ArgProxy` instead.',
)
def add_arg(*args: Any, **kwargs: Any) -> FuncArgs:
    """Wrap FuncArgs arguments in a function.

    Args:
        args: The arguments to argparse add_arguments.
        kwargs: The keyword arguments to argparse add arguments.

    Returns:
        A FuncArgs instance.
    """
    # `m` does not reference this function anymore, excluding from coverage
    return FuncArgs(args=list(args), kwargs=kwargs)  # pragma: no cover