withHelp
A route as help shows it: with the descriptions its help gives it, its parameters and its subcommands (those many
commands share from commonHelp).
import { commonHelp } from "#codebase/tcmts/cli/commands"; import type { Help } from "#codebase/tcmts/cli/commands"; import type { RouteShape } from "#codebase/tcmts/cli/help"; export function withHelp(r: RouteShape, h: Help | undefined): RouteShape { return { ...r, description: h?.description ?? r.description, phases: r.phases.map((p) => ({ ...p, model: { ...p.model, params: Object.fromEntries( Object.entries(p.model.params).map(([k, q]) => [ k, { ...q, description: h?.params?.[q.name] ?? commonHelp[q.name] ?? q.description }, ]), ), }, routes: p.routes.map((c) => withHelp(c, h?.routes?.[c.name])), })), }; }