cli.registry¶
The CLI command registry: how commands — first- and third-party — join otto.
A CommandSpec describes one top-level command or group: its name, a
loader (a live Typer app, a plain/async function, or a lazy "pkg.mod:attr"
string imported only on dispatch), the help line shown by otto --help
without importing the module, and dispatch metadata (lab_free,
output_dir, gate). First-party subcommands and third-party plugins
register through the same register_cli_command().
-
class otto.cli.registry.CommandSpec(name: str, loader: Any, help: str | None =
None, lab_free: bool =False, output_dir: bool =True, gate: bool =True, origin: str ='')¶ Bases:
objectOne registered top-level CLI command or group.
-
otto.cli.registry.CLI_COMMANDS : Registry[CommandSpec] =
<otto.registry.Registry object>¶ Every registered top-level
ottocommand or group, keyed by CLI name.
-
otto.cli.registry.register_cli_command(name: str, loader: Any, *, help: str | None =
None, lab_free: bool =False, output_dir: bool =True, gate: bool =True) None¶ Register a top-level
ottocommand or group.loader is a
typer.Typerapp (group), a plain/async function (leaf command), or a"pkg.mod:attr"string resolved lazily on dispatch. Name collisions raise immediately, naming both registering modules — there is deliberately no overwrite escape hatch for CLI commands.
-
otto.cli.registry.cli_command(*, options: type | None =
None, name: str | None =None, help: str | None =None, lab_free: bool =False, output_dir: bool =True, gate: bool =True) Callable[[...], Any]¶ Register an async function as a top-level
ottocommand.The ergonomics match
@instruction: anOttoContext-annotated parameter is injected (hidden from the CLI), andoptions=expands a pydantic-dataclass into flags. The command name defaults to the function name with underscores dashed.
- otto.cli.registry.resolve_spec_command(spec: CommandSpec) Any¶
Return the vendored-click command/group for spec, importing lazily.
A
"pkg.mod:attr"loader imports its module only now; a function loader is wrapped in a throwaway Typer (theexpose._synthesize_commandpattern); a Typer app converts via Typer’s own app→click converter.