complete
uses @bomb.sh/tab's RootCommand, which uses node:assert
tcm complete <shell> (the script) or tcm complete -- <words> (what can come next).
import { helpTcm, routes, routeTcm } from "#codebase/tcmts/cli/commands"; import { addParams, Sources } from "#codebase/tcmts/cli/complete"; import { childrenOf, lookup, shape, withHelp } from "#codebase/tcmts/cli/help"; import { RootCommand } from "@bomb.sh/tab"; export function complete(shell: string | undefined, words: string[], cwd: string): void { const t = new RootCommand(); const s = new Sources(cwd); addParams(t, withHelp(shape(routeTcm()), helpTcm), "", s); for (const name of Object.keys(routes())) { const route = lookup([name]); addParams(t.command(name, route.description ?? ""), route, name, s); for (const child of childrenOf(route)) addParams( t.command(`${name} ${child.name}`, child.description ?? ""), child, `${name} ${child.name}`, s, ); } if (shell) t.setup("tcm", "tcm", shell); else t.parse(words); }
uses
- tcmts.cli.commands.helpTcm
- tcmts.cli.commands.routeTcm
- tcmts.cli.commands.routes
- tcmts.cli.complete.Sources
- tcmts.cli.complete.addParams
- tcmts.cli.help.childrenOf
- tcmts.cli.help.lookup
- tcmts.cli.help.shape
- tcmts.cli.help.withHelp