refactor: adopt cobra's error handling and properly validate inputs#280
Open
mynk8 wants to merge 1 commit intomicrocks:masterfrom
Open
refactor: adopt cobra's error handling and properly validate inputs#280mynk8 wants to merge 1 commit intomicrocks:masterfrom
mynk8 wants to merge 1 commit intomicrocks:masterfrom
Conversation
e1f7d7e to
50b11c8
Compare
…aths Signed-off-by: mynk8 <mr.mayankgame@gmail.com>
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.
Description
The codebase utilizes cobra but does not use it's error handling features like cobra's PreRunE, Args, and RunE hooks were never adopted, and defer statements were skipped on error paths and never surfaced due to os.Exit(0) (cannot repro this just a speculation).
This refactor improves CI reliability by routing command validation through Cobra's standard Args / PreRunE / RunE flow. Invalid CLI usage now consistently returns a non-zero exit code while preserving actionable usage output, which is important for GitHub Actions and other automated environments that rely on process status.
The changes fix the problems with input validation with proper integration of cobra in the codebase.
I have added small tests for sanity checks as well, would like some feedback on this PR :)
Changes:
Bugs
Addresses #281