Documentation ¶
Index ¶
- Constants
- Variables
- func CheckErr(err error)
- func DefaultSubCommandRun() func(c *cobra.Command, args []string)
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func RequireNoArguments(c *cobra.Command, args []string)
- func StandardErrorMessage(err error) (string, bool)
- func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
- 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 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 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 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.
func TableWriterDefaultConfig ¶
func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
Types ¶
This section is empty.