fix(main): exit non-zero when Cobra returns an error - #269
Open
stantheman0128 wants to merge 1 commit into
Open
Conversation
Return 1 from run() so shell scripts see failures from invalid commands and flag errors. Subcommands that os.Exit with remote status are unchanged. Co-authored-by: Cursor <[email protected]>
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
When a Cobra subcommand returned an error,
mainlogged it but the process still exited0. That broke shell scripts and CI that rely on$?afterzeabur ...failures (for example invalid flags or missing required args).Refactor to
run() intandos.Exit(run())so anyExecute()error returns exit code1. Subcommands that callos.Exitwith a remote command status (service exec,server exec) are unchanged.Related to #268 (npm wrapper exit propagation); this fixes the Go entrypoint path.
AI disclosure
AI-assisted patch; human-reviewed by Stan Shih (stantheman0128) before publish.
Verification / Evidence
Before:
go run ./cmd/main.go this-subcommand-does-not-existexited 0 on Windows 11.After: same invocation exits 1.
What was not tested
npx zeaburend-to-end against the published npm tarball (localgo runonly).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.