Skip to content

Fix exit code propagation from subcommands#263

Open
lubluniky wants to merge 1 commit intoentireio:mainfrom
lubluniky:fix/exit-code-propagation
Open

Fix exit code propagation from subcommands#263
lubluniky wants to merge 1 commit intoentireio:mainfrom
lubluniky:fix/exit-code-propagation

Conversation

@lubluniky
Copy link

@lubluniky lubluniky commented Feb 11, 2026

Summary

  • Adds ExitCodeError type that allows subcommands to specify exit codes
  • Updates main.go to propagate exit codes instead of always using os.Exit(1)
  • Supports both direct ExitCodeError and SilentError wrapping ExitCodeError

Closes #256

Test plan

  • Unit tests for ExitCodeError type (wrapping, unwrapping, errors.As)
  • Verify SilentError wrapping ExitCodeError propagates code
  • Verify ExitCodeError wrapping SilentError is detectable
  • Verify fmt.Errorf wrapping preserves ExitCodeError
  • gofmt -s -w . passes
  • golangci-lint run passes (no new issues)
  • go test ./cmd/entire/cli/ passes

🤖 Generated with Claude Code

main.go previously hardcoded os.Exit(1) for all errors. Subcommands
that needed different exit codes (e.g., 2 for usage errors, 128 for
signal-related exits) had no way to specify them.

This adds an ExitCodeError type that wraps an error with an exit code.
main.go now checks for ExitCodeError via errors.As and uses the
specified code, falling back to 1 for plain errors. This works through
any wrapping chain including SilentError.

Closes entireio#256

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lubluniky lubluniky requested a review from a team as a code owner February 11, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

CLI always exits with status 1 on command errors (does not preserve underlying exit codes)

1 participant