Repository navigation
fix(cli): route unknown subcommands through the shared error envelope - #427
Merged
Merged
Conversation
#421 and #424 each passed alone and collide on main. #421's namespace handler printed its suggestion with console.error and set exitCode, so it never reached the envelope path #424 built: `--json` got human text and the `help:` line was spelled two different ways. The handler now throws a CommanderStructuralError carrying both the human bytes and the envelope, and both paths use one wording for the help line. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
ankitranjan7
pushed a commit
that referenced
this pull request
Aug 23, 2026
…ist (#428) Cloud's parity suite caught two ways hosted mode drifted from local after #424/#427. Hosted still passed includeCapturedStderrForUnknownOption, so it replayed Commander's captured stderr on top of the line structuralErrorFromCommander now formats itself, printing `error: unknown option ...` twice. The `help:` subcommand list also differed: local used declaration order and included Commander's auto `help` entry, hosted used manifest order without it. Both are sorted and drop `help` now, leaving only commands hosted mode genuinely cannot run (LOCAL strategy) as a difference. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
mainis red. #421 and #424 each passed on their own branch; neither was run against the other.#421 added a suggestion handler for unknown subcommands that calls
console.errorand setsprocess.exitCodedirectly. #424 built the shared envelope path that decides between human bytes and a machine envelope. Because #421's handler prints from inside the parser, it never reaches that path — sowebcmd adapter list rest --jsongot human text instead of JSON, and the two paths spelled the same sentence differently (Valid webcmd adapter commands:vshelp: valid subcommands for \webcmd adapter`:`).What changed
command:*handler throws aCommanderStructuralErrorinstead of printing.handleProgramParseErroralready owns the human-vs-envelope choice, so--jsonand-f yamlnow reach this failure like every other usage error.UNKNOWN_COMMANDenvelope with the suggestion'shelpbody.unknownSubcommandHelp()is the single source for that sentence, matchingstructuralHelpText()incommand-surface.ts. One wording, not two.handleProgramParseErrorrather than expecting the parser to print.Before / After
Both exit 2. #421's suggestion survives; #424's envelope now fires.
Tests
npm run typecheckclean.npx vitest run --project unit— 155 files, 2732 passed, 1 skipped, 0 failed (was 3 failed onmain).🤖 Generated with Claude Code