INNER CODE UNIT · Python
list_commands
mikel-brostrom/boxmot · boxmot/engine/cli.py:78
def list_commands(self, ctx: click.Context) -> list[str]:
"""List every registered command without importing its adapter module."""
del ctx
return [spec.name for spec in _COMMAND_SPECS]
def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None:
"""Import and cache only the command selected by Click."""
if command := self.commands.get(cmd_name):
return command
spec = _COMMAND_SPEC_BY_NAME.get(cmd_name)
if spec is None:
return None
module = importlib.import_module(spec.module)
command = getattr(module, spec.attribute)
if not isinstance(command, click.Command):