refactor(cli): bail early in the arg adapter instead of returning errors as data
Address review and cut ceremony: the adapter no longer models help/version/ errors as DshInvocation members. Commander owns those under exitOverride — it prints usage or the diagnostic and one try/catch in parseDshArgs turns the thrown CommanderError into process.exit with the intended code. bin.ts drops its help/version/error cases; the union is the three real modes. Domain checks bail via command.error(print + exit 1): --prompt rejects an empty task or a stray config/--resume, empty --resume= fails loud, and --host/--port are validated. A repeated --resume or a flag captured as a value is Commander's standard behavior, left alone (a bad id fails loud downstream). dsh --help discloses web via addHelpText. Net: args.ts 185 -> 112 lines. Also fixes review nits: built-bin e2e resolves on `close`; the /resume handoff uses `dsh --resume=<id> -- <config>` so a config named `web` stays a positional; and stale prose (cordis.yml comment, app-boot module doc + duplicate JSDoc, ui/README, two feature notes, an agent-loop test name) tracks the shipped state. Removes tui-demo's now-dead plugin-include dep and vendor/loader + app-boot tsconfig references.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
* dsh — command-line entry. Parses argv once through the Commander adapter and
|
||||
* switches on the resolved mode; dynamic imports keep unrelated modes out of
|
||||
* each dispatch path. `web` and headless prompts run their own module;
|
||||
* everything else opens the TUI. `--help`/`--version` print and exit 0; a parse
|
||||
* error prints to stderr and exits 1.
|
||||
* everything else opens the TUI. The adapter itself prints and exits for
|
||||
* `--help`/`--version`/a parse error, so only a valid mode reaches the switch.
|
||||
* @module @deepseek-ai/dsh/bin
|
||||
*/
|
||||
|
||||
@@ -45,13 +45,6 @@ switch (invocation.mode) {
|
||||
await runTui(invocation.config, invocation.resume)
|
||||
break
|
||||
}
|
||||
case 'help':
|
||||
case 'version':
|
||||
process.stdout.write(invocation.text)
|
||||
process.exit(0)
|
||||
case 'error':
|
||||
process.stderr.write(`${invocation.message}\n`)
|
||||
process.exit(1)
|
||||
default:
|
||||
invocation satisfies never
|
||||
throw new Error(`dsh: unhandled invocation mode ${JSON.stringify(invocation)}`)
|
||||
|
||||
Reference in New Issue
Block a user