Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FatalError ¶
FatalError outputs the error and exits with status exitCode.
func FatalResult ¶
func FatalResult(res ErrorResult, exitCode ExitCode)
FatalResult outputs the result and exits with status exitCode.
func PrintResult ¶
func PrintResult(res Result)
PrintResult is a convenient wrapper to provide feedback for complex data, where the contents can't be just serialized to JSON but requires more structure.
func SetFormat ¶
func SetFormat(f OutputFormat)
SetFormat can be used to change the output format at runtime
Types ¶
type ErrorResult ¶
ErrorResult is a result embedding also an error. In case of textual output the error will be printed on stderr.
type ExitCode ¶
type ExitCode int
ExitCode to be used for Fatal.
const ( // Success (0 is the no-error return code in Unix) Success ExitCode = iota // ErrGeneric Generic error (1 is the reserved "catchall" code in Unix) ErrGeneric // ErrNoConfigFile is returned when the config file is not found (3) ErrNoConfigFile // ErrNetwork is returned when a network error occurs (5) ErrNetwork // ErrCoreConfig represents an error in the cli core config, for example some basic // files shipped with the installation are missing, or cannot create or get basic // directories vital for the CLI to work. (6) ErrCoreConfig // ErrBadArgument is returned when the arguments are not valid (7) ErrBadArgument )
type OutputFormat ¶
type OutputFormat int
OutputFormat is an output format
const ( // Text is the plain text format, suitable for interactive terminals Text OutputFormat = iota // JSON format JSON )
func ParseOutputFormat ¶
func ParseOutputFormat(in string) (OutputFormat, bool)
ParseOutputFormat parses a string and returns the corresponding OutputFormat. The boolean returned is true if the string was a valid OutputFormat.
func (OutputFormat) String ¶
func (f OutputFormat) String() string