INNER CODE UNIT · Python
CommandFirstGroup
mikel-brostrom/boxmot · boxmot/engine/cli.py:75
class CommandFirstGroup(click.Group):
"""Click group with BoxMOT help formatting and lazy child resolution."""
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