Skip to content

fix(cli): keep exit farewell out of non-interactive output - #110

Merged
balajz merged 1 commit into
balajz:mainfrom
wuyua9:fix/cli-suppress-exit-farewell
Aug 15, 2026
Merged

fix(cli): keep exit farewell out of non-interactive output#110
balajz merged 1 commit into
balajz:mainfrom
wuyua9:fix/cli-suppress-exit-farewell

Conversation

@wuyua9

@wuyua9 wuyua9 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG (program behavior)
  • Typo
  • Improvement
  • Feature

What does this PR do?

main.go printed Thanks for using Pgxcli. and see you next time. after every successful Cobra command. This appended human-facing lines to non-interactive output such as --help and --version, making the output harder for scripts to consume.

The farewell is now emitted only after the interactive application returns successfully from internal/cli/root.go. Non-interactive commands remain clean, while normal REPL exits retain the existing message.

Validation

  • go test ./...
  • go build -o /tmp/pgxcli-farewell-final .
  • Built binary --help: no farewell lines
  • Built binary --version: pgxcli version 0.3.0, no farewell lines
  • git diff --check

@dcavalcante

Copy link
Copy Markdown
Contributor

The farewell on lines 84 and 85 runs before the cleanup in PersistentPostRunE, so if cleanup fails it will print before the command returns an error. This is fixed by moving those two lines to the end of, after all cleanup succeeds (immediately before return nil)

Also, would be good to have tests confirming that --help and --version do not include the farewell.

@balajz

balajz commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Good catch!

@balajz
balajz merged commit 2928cc6 into balajz:main Aug 15, 2026
8 checks passed
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.

3 participants