fix(cli): unknown flags exit 2 and list valid flags - #370
Merged
Conversation
Commander still rejects unknown options by name. The usage path now exits 2 and appends the command's valid flags so an agent can retry without a second --help call.
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. This review is advisory and does not block merging. |
exitOverride made --help throw commander.helpDisplayed. runCli now keeps that as a display exit so webcmd web --help stays exit 0.
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.
Unknown flags printed
error: unknown option '--foo'and exited 1. Agents treat 1 as a runtime error and still have to call--helpto learn the valid set.After
unknown optionso existing parsers keep workingUSAGE_ERROR), same as a missing required flag--helpbefore or after an unknown option still shows help and exits 0runCli, hosted adapter parse, and hosted built-in surfaces sharestructuralErrorFromCommanderHosted impact
Verification
npx tsc --noEmit— cleannpx vitest run --project unit src/command-surface.test.ts src/hosted/root-command-surface.test.ts src/hosted/runner.test.ts src/cli.test.ts src/fetch/command.test.ts src/hosted/browser-args.test.ts src/plugin-create-cli.test.ts— 529 passed