fix(cli): show banner on --help to match bare elastic output#391
Merged
Conversation
Closes #390 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
JoshMock
approved these changes
Jun 1, 2026
Member
JoshMock
left a comment
There was a problem hiding this comment.
I like less sadness where possible. 😆
Member
|
NOTICE.txt checks have been flapping. Not a blocker. |
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.
Summary
Bare
elasticprinted the ascii banner before the usage;elastic --helpprinted only the usage. They now produce identical output.The banner-rendering branch was inlined inside the no-args fallback in
src/cli.ts, so it never ran on Commander's--helppath. Moved it into aprogram.addHelpText('before', ...)hook on the root command so both invocations go through the same code, and dropped the duplicated banner write in the no-args branch.'before'(not'beforeAll') keeps subcommand--helpoutput (e.g.elastic stack --help) terse. The callback returns''when--jsonis set so--help --jsonstays valid JSON, and when the config hasbanner: false.Closes #390.
Test plan
npm run builddiff <(env -u NO_COLOR FORCE_COLOR=1 node dist/cli.js) <(env -u NO_COLOR FORCE_COLOR=1 node dist/cli.js --help)→ no diffenv -u NO_COLOR FORCE_COLOR=1 node dist/cli.js --help | head -10shows the colored ascii bannernode dist/cli.js --help --json | jq .name→"elastic"(no banner corruption)node dist/cli.js stack --help→ no banner (subcommand help unaffected)npm run test:unit→ 1436/1436 passMade with Cursor