Skip to content

Fix CLI error handling and bash completion description leakage - #121

Merged
thomas-vilte merged 1 commit into
masterfrom
dev
Jul 31, 2026
Merged

thomas-vilte merged 1 commit into
masterfrom
dev

Conversation

@thomas-vilte

@thomas-vilte thomas-vilte commented Jul 30, 2026 •

Copy link
Copy Markdown
Owner

Description

I improved the CLI's error handling by replacing log.Fatal and log.Fatalf calls with direct fmt.Fprintln(os.Stderr, err) and os.Exit(1). This change ensures that critical errors are always printed to stderr and the application exits with a non-zero status, addressing a silent failure mode where slog's redirection of log output could suppress fatal errors.

I also removed the -v alias for the verbose flag in main.go to prevent a collision with urfave/cli's built-in --version flag, which caused the verbose flag to be silently ignored.

Additionally, I fixed an issue in the bash shell completion script where descriptions from urfave/cli's --generate-shell-completion output were incorrectly included as completion candidates. The script now uses cut -d: -f1 to strip these descriptions, ensuring only valid command/flag names are suggested.

To verify the bash completion fix, I added a new integration test TestBashCompletion_StripsDescriptions that executes the generated bash script in a real bash environment.

Fixes #

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • Unit tests
  • Integration tests
  • Manual test: (describe below)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Test Plan & Evidence

Suggested Manual Verification

  • Unit Tests: Run go test ./... and ensure all tests pass
  • No Regressions: Verify that related features still work as expected

@thomas-vilte thomas-vilte changed the title placeholder Fix CLI error handling and bash completion description leakage Jul 30, 2026
@thomas-vilte thomas-vilte added fix Bug fixes test Testing, trials, and coverage labels Jul 30, 2026
@thomas-vilte
thomas-vilte merged commit c40164c into master Jul 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes test Testing, trials, and coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant