Commit 7bffe83
authored
refactor: single command-descriptor table for the CLI (#76)
CT1 (nuclear-review): CLI command knowledge lived in three unsynchronized
places — the kebab-case dispatch switch, the free-text usage() help
string, and (implicitly) unknown-command detection. Nothing enforced
sync between them, so a command could exist in one place and be silently
missing from another.
Introduces CommandDescriptor (name(s), help line(s), execute closure) and
one commandDescriptors() table that is now the single source of truth
for: dispatch, the grouped Commands: help block, and unknown-command
handling. usage() generates its Commands: section from the table instead
of a separately-maintained literal.
Coverage: 108 command names in the table — 52 with logic inlined directly
(previously inline switch-case bodies, now inline closures), 45 that call
into existing bespoke handler functions (ssh, tree, browser, the 23-name
tmux-compat group, etc.), and 11 pre-connection specials (version,
welcome, shortcuts, feedback, themes, claude-teams, omo/omx/omc, codex,
remote-daemon-status) that are documented in the table for help purposes
only — their execution stays in run()'s existing pre-socket-connection
if-chain, since some of them (version, welcome) must work even when
Programa isn't running.
Non-goal: this does not unify with the app-side v2 method switch in
Sources/TerminalController.swift (processV2Command) — that's server
code with different concerns (method routing vs. CLI UX) and is left
as-is.
Behavior is unchanged: same commands, same flags, same output, same
exit codes. Help text is byte-identical to the prior usage() output
(diffed old vs. new; verified via built binary).
subcommandUsage()/dispatchSubcommandHelp() (the per-command
detail text) are untouched — that mechanism sits outside CT1's three
named unsynchronized places and unifying it is left for a follow-up.1 parent e1e2b09 commit 7bffe83
1 file changed
Lines changed: 1413 additions & 999 deletions
0 commit comments