Files
dacli/src/cli.ts
T
sswandClaude d4cc3d09db feat(ssw-loop): P7 — generate command reference from commander tree (kill drift)
Per DESIGN §6 / user catch: ssw-loop subagent templates hand-code dacli command
syntax and drift (typ. missing --category). Command tree is now the single source.
- src/program.ts: extract buildProgram() (assembles commander tree, no parse/side-effect)
- src/cli.ts: slimmed to import buildProgram() + parse + top-level error handling
- scripts/gen-command-reference.ts: walk tree → .claude/.../command-reference.generated.md
  (190 commands w/ all options + defaults, incl --category/--column-naming)

Verified: tsc 0; cli entry smoke (form list) intact after refactor; generator emits
190 commands. (.claude side: generated ref + drift-check committed separately.)

Co-Authored-By: Claude <[email protected]>
2026-07-24 11:45:30 +08:00

25 lines
779 B
JavaScript

#!/usr/bin/env node
/**
* cli.ts — dacli TS 版入口
*
* 调用: `npx tsx src/cli.ts <command>` 或 `node --import tsx src/cli.ts <command>`
*
* 设计: 命令树在 src/program.ts 组装 (buildProgram, 无副作用),
* 本文件只负责 parse + 顶层错误处理。
*/
import { buildProgram } from './program.ts'
import { log } from './core/log.ts'
import { DacliError } from './core/types.ts'
// ----- main -----
buildProgram().parseAsync(process.argv).catch((err: unknown) => {
if (err instanceof DacliError) {
log.error(`${err.message}`)
if (err.raw && process.env.DACLI_DEBUG === '1') log.dim(err.raw)
process.exit(1)
}
log.error(`${(err as Error).message}`)
if (process.env.DACLI_DEBUG === '1') console.error(err)
process.exit(1)
})