# _command_defs

URL: /milo-cli/api/milo/_command_defs/
Section: milo
Description: Command definition types and helpers.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/_command_defs/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_command_defs%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_command_defs%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_command_defs%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_command_defs%2Findex.txt)

Module

#
`_command_defs`

Command definition types and helpers.

7Classes2Functions

## Classes

`GlobalOption`

6

▼

A CLI-wide option available to all commands via Context.

A CLI-wide option available to all commands via Context.

#### Attributes

Name
Type
Description

`name`

`str`

—

`short`

`str`

—

`option_type`

`type`

—

`default`

`Any`

—

`description`

`str`

—

`is_flag`

`bool`

—

`ResourceDef`

5

▼

A registered MCP resource.

A registered MCP resource.

#### Attributes

Name
Type
Description

`uri`

`str`

—

`name`

`str`

—

`description`

`str`

—

`handler`

`Callable[..., Any]`

—

`mime_type`

`str`

—

`PromptDef`

4

▼

A registered MCP prompt.

A registered MCP prompt.

#### Attributes

Name
Type
Description

`name`

`str`

—

`description`

`str`

—

`handler`

`Callable[..., Any]`

—

`arguments`

`tuple[dict[str, Any], ...]`

—

`CommandDef`

11

▼

A registered CLI command.

A registered CLI command.

#### Attributes

Name
Type
Description

`name`

`str`

—

`description`

`str`

—

`handler`

`Callable[..., Any]`

—

`schema`

`dict[str, Any]`

—

`aliases`

`tuple[str, ...]`

—

`tags`

`tuple[str, ...]`

—

`hidden`

`bool`

—

`examples`

`tuple[dict[str, Any], ...]`

—

`confirm`

`str`

—

`annotations`

`dict[str, Any]`

—

`display_result`

`bool`

—

`LazyCommandDef`

4

▼

A command whose handler is imported on first use.

Stores a dotted import path (``module:attribute`…

A command whose handler is imported on first use.

Stores a dotted import path (`module:attribute`) and defers the
actual import until the command is invoked. This keeps CLI startup
fast even with dozens of commands.

If schema is provided upfront, MCP`tools/list`and llms.txt
can be generated without importing the handler module at all.

#### Methods

`schema`

0

`dict[str, Any]`

▼

Return pre-computed schema or resolve to get it.

property

`def schema(self) -> dict[str, Any]`

##### Returns

`dict[str, Any]`

`handler`

0

`Callable[..., Any]`

▼

Resolve and return the handler function.

property

`def handler(self) -> Callable[..., Any]`

##### Returns

`Callable[..., Any]`

`resolve`

0

`CommandDef`

▼

Import the handler and cache as a full CommandDef. Thread-safe.

Raises `LazyIm…

`def resolve(self) -> CommandDef`

Import the handler and cache as a full CommandDef. Thread-safe.

Raises`LazyImportError`if the module or attribute cannot
be imported, wrapping the original exception with a clear message.

##### Returns

`CommandDef`

Internal Methods
1

▼

`__init__`

11

▼

`def __init__(self, name: str, import_path: str, description: str = '', *, schema: dict[str, Any] | None = None, aliases: tuple[str, ...] | list[str] = (), tags: tuple[str, ...] | list[str] = (), hidden: bool = False, examples: tuple[dict[str, Any], ...] | list[dict[str, Any]] = (), confirm: str = '', annotations: dict[str, Any] | None = None, display_result: bool = True) -> None`

##### Parameters

Name
Type
Description

`name`
`—`

`import_path`
`—`

`description`
`—`

Default:`''`

`schema`
`—`

Default:`None`

`aliases`
`—`

Default:`()`

`tags`
`—`

Default:`()`

`hidden`
`—`

Default:`False`

`examples`
`—`

Default:`()`

`confirm`
`—`

Default:`''`

`annotations`
`—`

Default:`None`

`display_result`
`—`

Default:`True`

`InvokeResult`

5

▼

Result of CLI.invoke() for testing.

Result of CLI.invoke() for testing.

#### Attributes

Name
Type
Description

`output`

`str`

—

`exit_code`

`int`

—

`result`

`Any`

—

`exception`

`Exception | None`

—

`stderr`

`str`

—

`LazyImportError`

1

▼

Raised when a lazy command's import fails.

Wraps the original exception with the command name and …

Raised when a lazy command's import fails.

Wraps the original exception with the command name and import path
so callers can provide actionable error messages.

#### Methods

Internal Methods
1

▼

`__init__`

3

▼

`def __init__(self, command_name: str, import_path: str, cause: Exception) -> None`

##### Parameters

Name
Type
Description

`command_name`
`—`

`import_path`
`—`

`cause`
`—`

## Functions

`_make_command_def`

10

`CommandDef`

▼

Build a CommandDef from a function and decorator kwargs.

`def _make_command_def(name: str, func: Callable, *, description: str = '', aliases: tuple[str, ...] = (), tags: tuple[str, ...] = (), hidden: bool = False, examples: tuple[dict[str, Any], ...] = (), confirm: str = '', annotations: dict[str, Any] | None = None, display_result: bool = True) -> CommandDef`

##### Parameters

Name
Type
Description

`name`
`str`

`func`
`Callable`

`description`
`str`

Default:`''`

`aliases`
`tuple[str, ...]`

Default:`()`

`tags`
`tuple[str, ...]`

Default:`()`

`hidden`
`bool`

Default:`False`

`examples`
`tuple[dict[str, Any], ...]`

Default:`()`

`confirm`
`str`

Default:`''`

`annotations`
`dict[str, Any] | None`

Default:`None`

`display_result`
`bool`

Default:`True`

##### Returns

`CommandDef`

`_is_context_param`

1

`bool`

▼

Check if a parameter is a Context injection point.

`def _is_context_param(param: inspect.Parameter) -> bool`

##### Parameters

Name
Type
Description

`param`
`inspect.Parameter`

##### Returns

`bool`
