execute
uses tcmts.cli.help.usageError, which uses tcmts.cli.help.usageOf, which uses tcmts.cli.style.bold, which uses node:util
A parsed command line, if it asks to run the command: help and the version are printed instead, and a line the command doesn't accept is a usage error saying why.
import { helpText, usageError } from "#codebase/tcmts/cli/help"; import { Printed } from "#codebase/tcmts/cli/main"; import { dim } from "#codebase/tcmts/cli/style"; import { UsageError } from "#codebase/tcmts/cli/ui"; import { IR_VERSION } from "#codebase/tcmts/core/hash"; import { TS_VERSION } from "#codebase/tcmts/core/program"; export function execute<R extends { ok: boolean }>( cmd: string | undefined, r: R, ): Extract<R, { method: "execute" }> { const x = r as unknown as { ok: boolean; method?: string; path?: string[]; code: string; issues?: { message: string; path?: unknown[] }[]; }; const where = [...(cmd ? [cmd] : []), ...(x.path ?? [])]; if (!x.ok) throw new UsageError(usageError(where, x)); if (x.method === "help") throw new Printed(helpText(where)); if (x.method === "version") throw new Printed(`tcm ${dim(`(hash format v${IR_VERSION}, TypeScript ${TS_VERSION})`)}`); return r as never; }
uses
- tcmts.cli.help.helpText
- tcmts.cli.help.usageError
- tcmts.cli.main.Printed
- tcmts.cli.style.dim
- tcmts.cli.ui.UsageError
- tcmts.core.hash.IR_VERSION
- tcmts.core.program.TS_VERSION
used by
- tcmts.cli.main.dispatch
- tcmts.cli.run.runAddUpdate
- tcmts.cli.run.runAlias
- tcmts.cli.run.runApps
- tcmts.cli.run.runAt
- tcmts.cli.run.runBranch
- tcmts.cli.run.runBuild
- tcmts.cli.run.runBuilds
- tcmts.cli.run.runChangelog
- tcmts.cli.run.runCheck
- tcmts.cli.run.runComplete
- tcmts.cli.run.runContribute
- tcmts.cli.run.runContribution
- tcmts.cli.run.runData
- tcmts.cli.run.runDepsDependentsDocs
- tcmts.cli.run.runDescribe
- tcmts.cli.run.runDev
- tcmts.cli.run.runDiff
- tcmts.cli.run.runEdit
- tcmts.cli.run.runExport
- tcmts.cli.run.runFind
- tcmts.cli.run.runFmt
- tcmts.cli.run.runHistory
- tcmts.cli.run.runImport
- tcmts.cli.run.runInit
- tcmts.cli.run.runJobs
- tcmts.cli.run.runLib
- tcmts.cli.run.runLint
- tcmts.cli.run.runLs
- tcmts.cli.run.runLsp
- tcmts.cli.run.runMergeSwitch
- tcmts.cli.run.runMigrate
- tcmts.cli.run.runMirror
- tcmts.cli.run.runMv
- tcmts.cli.run.runPack
- tcmts.cli.run.runPackages
- tcmts.cli.run.runPatch
- tcmts.cli.run.runPull
- tcmts.cli.run.runPush
- tcmts.cli.run.runRegistry
- tcmts.cli.run.runRelease
- tcmts.cli.run.runReleases
- tcmts.cli.run.runRemote
- tcmts.cli.run.runReset
- tcmts.cli.run.runResolve
- tcmts.cli.run.runRevert
- tcmts.cli.run.runRm
- tcmts.cli.run.runRun
- tcmts.cli.run.runSearch
- tcmts.cli.run.runServe
- tcmts.cli.run.runStart
- tcmts.cli.run.runStatus
- tcmts.cli.run.runTest
- tcmts.cli.run.runTodo
- tcmts.cli.run.runUpgrade
- tcmts.cli.run.runUser
- tcmts.cli.run.runVerify
- tcmts.cli.run.runView
- tcmts.cli.run.runWatch