Skip to content

refactor(cli): give each command its own help screen - #5181

Open
orangeCatDeveloper wants to merge 1 commit into
apache:mainfrom
orangeCatDeveloper:docs/cli-output-locale-policy
Open

refactor(cli): give each command its own help screen#5181
orangeCatDeveloper wants to merge 1 commit into
apache:mainfrom
orangeCatDeveloper:docs/cli-output-locale-policy

Conversation

@orangeCatDeveloper

@orangeCatDeveloper orangeCatDeveloper commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

maka --help printed 110 lines. Sixty-two of them were the Runtime Host surface — service, access, plugin, profile and their six option sections — which only an operator installing a background service needs. Someone running the tool for the first time met a wall of administration syntax before finding out what it does, and the root screen carried section titles like Managed Runtime Host direct-peer options (Linux or macOS), which is a structure leaking through its own help.

Help is now layered the way run and activate already were:

maka --help                        25 lines: top-level commands and the TUI options
maka runtime-host --help           the nine Runtime Host commands, one line each
maka runtime-host serve --help     that command's own options
maka update --help                 a screen it never had
maka session-export --help         likewise

Every screen has the same shape — Usage:, then Commands: where there is
more than one, then Options:. The section titles shed the qualifiers they
needed only while six of them shared the root screen: Managed Runtime Host service install options (Linux or macOS) is just Install options (Linux or macOS) once Usage: maka runtime-host service sits above it.

maka update --help, session-export --help and session-import --help previously answered Unexpected argument or exited 1 with a usage line on stderr. They are real screens now, which matters because the root no longer spells their flags out.

Column widths are measured from the entries rather than fixed, so a development launcher (npm run cli:dev --) aligns like the packaged maka does. The previous hardcoded width broke on the longer name — -- --acpServe ACP v1… — which the existing test caught.

Refs #2672

Verification

packages/cli dist suite         937 pass / 0 fail
packages/cli tsc --noEmit       0 errors
check-tui-copy                  ok (18 files)
check-locale-hygiene            passed
npm run format:check            clean

Before and after, root help:

$ maka --help | wc -l
110

$ maka --help | wc -l
25

Two existing assertions changed, both because they pinned the old shape rather than a behavior: one matched an exact column width (/^ maka {14}Start the TUI$/), the other required runtime-host serve to appear in the root screen. They now assert the layering — that the root names runtime-host once and points at it, that it stays under 30 lines, that every summary starts in one column whatever the launcher name costs, and that the launcher name survives into the second and third level.

Three new assertions guard the move itself, because the new module was
generated by a script that lifted the old text and regrouped it — which is
exactly where content gets dropped or mis-filed. One walks every command the
parser accepts and fails if it appears on no screen; removing activate from
the topic table fails it with runtime-host activate is unreachable from any help screen. That test found nothing when written, because it was written
after a review caught what it would have caught:

  • runtime-host activate was dropped outright — the generator's topic list
    omitted activate and connect, so a command the parser still accepts
    appeared on no screen and answered Unexpected runtime-host activate option.
  • MAKA_RUNTIME_HOST_ACCESS_CREDENTIAL was lost with the root Options
    rewrite. It is the credential profile set reads when --credential-env is
    omitted, so the advertised default invocation had no documented way to supply
    one. It now sits under runtime-host profile --help.
  • session-export / session-import lost their grammar to ... in the root
    screen while neither had a --help to move it to.

Review focus

This replaces what this PR held before — a decision to record the English-only help as a contract. That framing was wrong on two counts, and the second one is the reason for this rewrite:

  • The argument for it was that help gets pasted and searched, so one language keeps it quotable. That holds for error messages, not for help text, which is read once in a terminal.
  • The follow-up argument — that too little of the file is translatable prose to bother — does not survive counting: 57 of 58 option lines carry a description, and about two thirds of the non-blank lines contain translatable text, not the small fraction it looks like at a glance.

So the honest position is that the root help was never decided to be English; it was never localized, and it was also too long to be useful in any language. This PR fixes the length and the structure. Localizing the now-25-line root screen is a separate, much smaller change, and nothing here forecloses it.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code — restructured the help, wired the per-command dispatch, updated the tests, and wrote this description. A second model (Codex) argued against the previous framing of this PR and supplied the line counts that overturned it. The commit carries a Generated-by: Claude Code trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — maka --help no longer lists the Runtime Host subcommands; they moved to maka runtime-host --help
  • No

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Sep 11, 2026
@orangeCatDeveloper orangeCatDeveloper changed the title docs(cli): make the non-interactive output language a contract refactor(cli): give each command its own help screen Sep 11, 2026
@orangeCatDeveloper
orangeCatDeveloper force-pushed the docs/cli-output-locale-policy branch 2 times, most recently from c6a87de to 7d078f7 Compare September 11, 2026 05:43
@orangeCatDeveloper
orangeCatDeveloper marked this pull request as ready for review September 11, 2026 05:46
@github-actions github-actions Bot added effort/L Under 1000 readable lines and removed effort/S Under 100 readable lines labels Sep 11, 2026
`maka --help` printed 110 lines, 62 of them the Runtime Host service,
access, plugin and profile surfaces that only an operator installing a
service needs. A newcomer asking what the tool does met a wall of
administration syntax, and the six option sections meant the root screen
carried titles like "Managed Runtime Host direct-peer options".

Help is now layered the way `run` and `activate` already were: the root
lists the top-level commands and the TUI options in 25 lines, and
`runtime-host --help` and `runtime-host <command> --help` carry what
belongs to them. `update --help` gains a screen it never had — it used to
answer "Unexpected argument".

Column widths are measured rather than fixed, so a development launcher
("npm run cli:dev --") aligns like the packaged `maka` name.

Generated-by: Claude Code
@orangeCatDeveloper
orangeCatDeveloper force-pushed the docs/cli-output-locale-policy branch from 7d078f7 to ea0a763 Compare September 11, 2026 05:58

@me2seeks me2seeks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 5181 Review

结论

APPROVE
分层 help 重构行为保持:parseRuntimeHostCommand(argv, cliCommand='maka') 新参数有默认值,唯一生产调用方 cli-core.ts:96 传入 launcher 名;--help 提前返回不影响既有子命令解析顺序(help 之前原本也没有子命令匹配路径,旧代码裸 maka 走 error,新代码走 host overview,属意图内变更)。maka runtime-host connect --help 落在 isRuntimeHostHelpTopic(SUBCOMMANDS 含 activate,其 lines 同时文档化 connect,runtime-host-help.ts:25),与描述"九个 Runtime Host 命令"一致。新增"每命令可达成"覆盖测试与 MAKA_RUNTIME_HOST_ACCESS_CREDENTIAL 保留测试覆盖了分层的主要回归面。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants