Skip to content

fix(cli): show banner on --help to match bare elastic output#391

Merged
JoshMock merged 2 commits into
mainfrom
fix/banner-on-help
Jun 1, 2026
Merged

fix(cli): show banner on --help to match bare elastic output#391
JoshMock merged 2 commits into
mainfrom
fix/banner-on-help

Conversation

@l-trotta
Copy link
Copy Markdown
Contributor

@l-trotta l-trotta commented Jun 1, 2026

Summary

Bare elastic printed the ascii banner before the usage; elastic --help printed 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 --help path. Moved it into a program.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 --help output (e.g. elastic stack --help) terse. The callback returns '' when --json is set so --help --json stays valid JSON, and when the config has banner: false.

Closes #390.

Test plan

  • npm run build
  • diff <(env -u NO_COLOR FORCE_COLOR=1 node dist/cli.js) <(env -u NO_COLOR FORCE_COLOR=1 node dist/cli.js --help) → no diff
  • env -u NO_COLOR FORCE_COLOR=1 node dist/cli.js --help | head -10 shows the colored ascii banner
  • node 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 pass

Made with Cursor

l-trotta and others added 2 commits June 1, 2026 15:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 9.42s
✅ REPOSITORY gitleaks yes no no 61.74s
✅ REPOSITORY git_diff yes no no 0.06s
✅ REPOSITORY secretlint yes no no 33.6s
✅ REPOSITORY trivy yes no no 19.19s
✅ TYPESCRIPT eslint 1 0 0 3.39s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Copy link
Copy Markdown
Member

@JoshMock JoshMock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like less sadness where possible. 😆

@JoshMock
Copy link
Copy Markdown
Member

JoshMock commented Jun 1, 2026

NOTICE.txt checks have been flapping. Not a blocker.

@JoshMock JoshMock merged commit cb4becd into main Jun 1, 2026
21 of 23 checks passed
@JoshMock JoshMock deleted the fix/banner-on-help branch June 1, 2026 18:05
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.

elastic and elastic --help should show the same output

2 participants