fix(cli): write error message to stderr before showing help#34604
fix(cli): write error message to stderr before showing help#34604Robin1987China wants to merge 1 commit into
Conversation
When the user passes an unknown argument or invalid value, the .fail() handler calls cli.showHelp() but never writes the error message to stderr. This makes opencode --unkown-flag silently show help output identical to opencode --help, leaving the user unaware of the error. Closes anomalyco#29390
|
The following comment was made by an LLM, it may be inaccurate: I found several related PRs that address similar CLI error handling issues:
These PRs (especially #31228 and #31488) appear to be addressing the exact same problem as PR #34604 - ensuring error messages are displayed before help output when the user provides invalid arguments. You may want to verify whether these earlier PRs were closed without merging or if there's a reason they need to be revisited with this new approach. |
Issue for this PR
Closes #29390
Type of change
What does this PR do?
When the user passes an unknown argument or invalid value, the .fail() handler calls cli.showHelp() but never writes the error message to stderr. This makes
opencode --unknown-flagsilently show help output identical toopencode --help, leaving the user unaware of the error.This adds
process.stderr.write(msg + "\n")before showing help so the user sees what went wrong.How did you verify your code works?
Checklist