Skip to content

fix(opencode): print CLI parser errors#29418

Open
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/cli-fail-error-message
Open

fix(opencode): print CLI parser errors#29418
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/cli-fail-error-message

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 26, 2026

Issue for this PR

Closes #29390

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Prints the yargs parser error message before showing top-level help for invalid CLI arguments.

Before this change, opencode --unkown-flag exited non-zero but produced the same visible output as opencode --help, so users could not tell what was wrong. The fail handler already receives the parser message; this writes it to stderr before rendering help.

How did you verify your code works?

  • PATH="$HOME/.bun/bin:$PATH" bun test test/cli/invalid-args.test.ts
  • PATH="$HOME/.bun/bin:$PATH" bun test test/cli/invalid-args.test.ts test/cli/help/help-snapshots.test.ts test/cli/smokes/read-only.test.ts
  • PATH="$HOME/.bun/bin:$PATH" bun typecheck
  • git diff --check

I also ran .husky/pre-push; it failed in the unrelated @opencode-ai/console-support package because local dependencies/types such as @solidjs/meta, @solidjs/router, solid-js, vite, and generated @opencode-ai/console-core/... modules were missing. The opencode package checks above passed.

Screenshots / recordings

N/A - CLI stderr behavior only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate PRs found:

  1. fix(cli): output error message on .fail() (fixes #29390) #29400 - fix(cli): output error message on .fail() (fixes #29390)

  2. fix(opencode): show error message in CLI .fail() handler #29393 - fix(opencode): show error message in CLI .fail() handler

Why they're related: All three PRs (#29418, #29400, #29393) address the same issue (#29390) of displaying CLI parser error messages. PR #29418 (current) and the other two are likely duplicate efforts to fix the invalid CLI arguments error display problem. You may want to check if one of these has already been merged or if they should be consolidated.

@YOMXXX
Copy link
Copy Markdown
Author

YOMXXX commented May 26, 2026

Checked the duplicate candidates.

So the implementation scope is intentionally small, but the difference is that this PR keeps the behavior covered at the CLI boundary that regressed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(opencode): CLI .fail() handler swallows error message

1 participant