fix: add trailing newline to help output#26374
Conversation
When `opencode auth` is run without a subcommand, yargs' demandCommand fires and the help text is printed via the show() callback. yargs hands the callback help text without a final newline, so the shell prompt ends up glued to the last help line. Ensure show() writes a trailing EOL. Fixes anomalyco#24813
|
The following comment was made by an LLM, it may be inaccurate: Potential duplicate found:
This PR appears to address the same issue (trailing newlines in help output). You may want to check if PR #22125 was already merged or if there's overlap in the implementation. |
Cover the other branch of show(): when help text does not begin with "opencode " we print the logo first, then the text. Mirror the EOL handling so this branch also ends with a newline, matching the non-logo path. Aligns coverage with the broader fix proposed in Signed-off-by: praveen9354 <praveen9354@gmail.com> anomalyco#22125.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Confirmed the fix is correct - yargs strips trailing whitespace from help output and both branches of the |
Consolidates the per-branch `endsWith(EOL) ? x : x + EOL` ternaries into a single `content` constant computed at the top of show(). Both the logo-prefixed and bare-help-output paths now use the same prepared string. Functionally equivalent to the previous commit; just clearer and avoids repeating the EOL fix logic in two places. No behavioral change — existing help-output assertion in PR anomalyco#26374 still holds. Also unblocks future formatting helpers that need consistent end-of-output handling without duplicating the check. Signed-off-by: praveen9354 <praveen9354@gmail.com>
|
@malventano gentle ping — thanks again for confirming on 2026-05-20 that the fix is correct (yargs strips trailing whitespace and both branches of |
Issue for this PR
Closes #24813
Type of change
What does this PR do?
When
opencode authis run without a subcommand, yargs'demandCommandfires and the help text is printed via theshow()callback inpackages/opencode/src/index.ts. yargs hands the callback help text without a final newline, so the shell prompt ends up glued to the last help line.This patches both branches of
show()to ensure trailing EOL:UI.logo()then the help body)opencodebranch (top-level help)#22125 contains the same fix bundled with a much larger LSP/compaction/i18n change set; this PR is a focused, mergeable extraction so the trailing-newline issue can land independently.
How did you verify your code works?
bun typecheckclean across all 12 workspace packages.bun test --timeout 30000frompackages/opencode/runs cleanly on the affected file (no test exists for theshow()callback specifically; the change is mechanical).devand is resolved on this branch by runningopencode authand observing the prompt now appears on its own line.Screenshots / recordings
N/A — terminal-output behavior; not a UI change.
Checklist