INNER CODE UNIT · Python
list_commands
evalstate/fast-agent · src/fast_agent/cli/main.py:97
def list_commands(self, ctx: Context) -> list[str]:
del ctx
return sorted(self.lazy_subcommands)
def get_command(self, ctx: Context, cmd_name: str) -> Command | None:
if ctx.meta.get(_ROOT_HELP_CONTEXT_KEY) is True:
short_help = self.lazy_subcommand_help.get(cmd_name)
return TyperCommand(name=cmd_name, help=short_help) if short_help is not None else None
target = self.lazy_subcommands.get(cmd_name)
if not target:
return None
module_path, app_name = target.split(":", 1)
module = importlib.import_module(module_path)
typer_app = getattr(module, app_name)
command = typer.main.get_command(typer_app)
command.name = cmd_name
return command