INNER CODE UNIT · Python
get_command
evalstate/fast-agent · src/fast_agent/cli/main.py:101
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
def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None:
rows = [
(command_name, self.lazy_subcommand_help[command_name])
for command_name in self.list_commands(ctx)