Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d0c8e6
commit dad6268
Showing
106 changed files
with
1,597 additions
and
314 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func bindFlagsToViper(cmd *cobra.Command) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
|
||
return viper.BindPFlags(cmd.PersistentFlags()) | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package errorsutils | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
type ErrorWithExitCode struct { | ||
Err error | ||
ExitCode int | ||
} | ||
|
||
func (e ErrorWithExitCode) Unwrap() error { | ||
return e.Err | ||
} | ||
|
||
func (e ErrorWithExitCode) Error() string { | ||
return fmt.Sprintf("error with exit code '%v': %d", e.Err, e.ExitCode) | ||
} | ||
|
||
func (e ErrorWithExitCode) Is(err error) bool { | ||
_, ok := err.(ErrorWithExitCode) | ||
return ok | ||
} | ||
|
||
func IsErrorWithExitCode(err error) bool { | ||
return errors.Is(err, ErrorWithExitCode{}) | ||
} | ||
|
||
func NewErrorWithExitCode(err error, exitCode int) *ErrorWithExitCode { | ||
return &ErrorWithExitCode{ | ||
Err: err, | ||
ExitCode: exitCode, | ||
} | ||
} |
This file contains 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
Oops, something went wrong.