Documentation ¶
Index ¶
- Constants
- Variables
- func AskForConfirmation(s string, stdin io.Reader, stdout io.Writer) bool
- func CheckResponse(err error, expectedStatusCode int, response *http.Response)
- func EnvVarExamplesHelpMessage(name string) string
- func ExactArgs(cmd *cobra.Command, args []string, l int)
- func ExpectDependency(logger *logrusx.Logger, dependencies ...interface{})
- func FailSilently(cmd *cobra.Command) error
- func Fatalf(message string, args ...interface{})
- func FormatResponse(o interface{}) string
- func MinArgs(cmd *cobra.Command, args []string, min int)
- func Must(err error, message string, args ...interface{})
- func PrintCollection(cmd *cobra.Command, collection OutputCollection)
- func PrintErrors(cmd *cobra.Command, errs map[string]error)
- func PrintRow(cmd *cobra.Command, row OutputEntry)
- func RangeArgs(cmd *cobra.Command, args []string, r []int)
- func RegisterFormatFlags(flags *pflag.FlagSet)
- func Version(gitTag, gitHash, buildTime *string) *cobra.Command
- type OutputCollection
- type OutputEntry
- type OutputHeader
Constants ¶
const ( FormatQuiet format = "quiet" FormatTable format = "table" FormatJSON format = "json" FormatJSONPretty format = "json-pretty" FlagQuiet = "quiet" FlagFormat = "format" None = "<none>" )
Variables ¶
var ( // ErrNilDependency is returned if a dependency is missing. ErrNilDependency = errors.New("a dependency was expected to be defined but is nil. Please open an issue with the stack trace") // ErrNoPrintButFail is returned to detect a failure state that was already reported to the user in some way ErrNoPrintButFail = errors.New("this error should never be printed") )
Functions ¶
func AskForConfirmation ¶ added in v0.0.119
asks for confirmation with the question string s and reads the answer pass nil to use os.Stdin and os.Stdout
func CheckResponse ¶
CheckResponse fatals if err is nil or the response.StatusCode does not match the expectedStatusCode
func EnvVarExamplesHelpMessage ¶
EnvVarExamplesHelpMessage returns a string containing documentation on how to use environment variables.
func ExpectDependency ¶ added in v0.0.37
ExpectDependency expects every dependency to be not nil or it fatals.
func FailSilently ¶ added in v0.0.152
FailSilently is supposed to be used within a commands RunE function. It silences cobras error handling and returns the ErrNoPrintButFail error.
func Fatalf ¶
func Fatalf(message string, args ...interface{})
Fatalf prints to os.Stderr and exists with code 1.
func FormatResponse ¶
func FormatResponse(o interface{}) string
FormatResponse takes an object and prints a json.MarshalIdent version of it or fatals.
func PrintCollection ¶ added in v0.0.152
func PrintCollection(cmd *cobra.Command, collection OutputCollection)
func PrintRow ¶ added in v0.0.152
func PrintRow(cmd *cobra.Command, row OutputEntry)
func RangeArgs ¶ added in v0.0.6
RangeArgs fatals if args does not satisfy any of the lengths set in r.
func RegisterFormatFlags ¶ added in v0.0.152
Types ¶
type OutputCollection ¶ added in v0.0.152
type OutputCollection interface { OutputHeader Table() [][]string Interface() interface{} Len() int }
type OutputEntry ¶ added in v0.0.152
type OutputEntry interface { OutputHeader Fields() []string Interface() interface{} }
type OutputHeader ¶ added in v0.0.152
type OutputHeader interface {
Header() []string
}