Documentation
¶
Index ¶
- Constants
- Variables
- func CheckErr(err error)
- func DefaultSubCommandRun() func(c *cobra.Command, args []string)
- func Exists(fileToCheck string) bool
- func GenerateGoCode(filePath, codeTemplate, name string, o any) error
- func GetDirectoryFromPath(filePath string) string
- func GetGoVersion() string
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func PathExists(path string) (bool, error)
- func RequireNoArguments(c *cobra.Command, args []string)
- func StandardErrorMessage(err error) (string, bool)
- func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error
Constants ¶
const (
// DefaultErrorExitCode defines the default exit code.
DefaultErrorExitCode = 1
)
Variables ¶
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
Functions ¶
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user-friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-IAM commands.
func DefaultSubCommandRun ¶
DefaultSubCommandRun prints a command's help string to the specified output if no arguments (sub-commands) are provided, or a usage error otherwise.
func GenerateGoCode ¶
GenerateGoCode generate go source file.
func GetDirectoryFromPath ¶
func GetGoVersion ¶ added in v0.2.0
func GetGoVersion() string
func MultilineError ¶
MultilineError returns a string representing an error that splits sub errors into their own lines. The returned string will end with a newline.
func MultipleErrors ¶
MultipleErrors returns a newline delimited string containing the prefix and referenced errors in standard form.
func PathExists ¶ added in v0.2.0
func RequireNoArguments ¶
RequireNoArguments exits with a usage error if extra arguments are provided.
func StandardErrorMessage ¶
StandardErrorMessage translates common errors into a human readable message, or returns false if the error is not one of the recognized types. It may also log extended information to klog.
This method is generic to the command in use and may be used by non-IAM commands.
Types ¶
This section is empty.