refactor(cmd): replace os.Exit/log.Fatalf with RunE and add Args validators#344
Closed
Harishrs2006 wants to merge 1 commit intomicrocks:masterfrom
Closed
Conversation
…dators Migrate all subcommands from Run to RunE and remove process-termination patterns so errors propagate cleanly through Cobra to main(): - cmd.go: add SilenceErrors so errors are not double-printed - import, import-url, import-dir: ExactArgs(1) replaces manual len(args) guard + os.Exit; RunE returns wrapped errors - test: ExactArgs(3) replaces direct os.Args inspection; PreRunE validates --waitFor format and runner type before network calls; RunE returns errors - start, stop: RunE replaces log.Fatalf with fmt.Errorf - Extract parseWaitForMilliseconds helper for testability Fixes microcks#281 Signed-off-by: Harish R S <harishrs21082006@gmail.com>
Author
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.
SilenceErrors: trueto root command to prevent errors being printed twice by both Cobra andmain().import,import-url,import-dir:cobra.ExactArgs(1)replaces manuallen(args)guard andos.Exit;RunEreturns wrapped errors.test:cobra.ExactArgs(3)replaces directos.Argsinspection;PreRunEvalidates--waitForformat and runner type before any network call; extractparseWaitForMillisecondshelper for testabilitystart,stop:RunEreplaceslog.Fatalfwithfmt.Errorfos.Exit— errors propagate cleanly tomain().Fixes #281