cmdx

package
v0.0.128 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2020 License: Apache-2.0 Imports: 11 Imported by: 58

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilDependency = errors.New("a dependency was expected to be defined but is nil. Please open an issue with the stack trace")

ErrNilDependency is returned if a dependency is missing.

Functions

func AskForConfirmation added in v0.0.119

func AskForConfirmation(s string, stdin io.Reader, stdout io.Writer) bool

asks for confirmation with the question string s and reads the answer pass nil to use os.Stdin and os.Stdout

func CheckResponse

func CheckResponse(err error, expectedStatusCode int, response *http.Response)

CheckResponse fatals if err is nil or the response.StatusCode does not match the expectedStatusCode

func EnvVarExamplesHelpMessage

func EnvVarExamplesHelpMessage(name string) string

EnvVarExamplesHelpMessage returns a string containing documentation on how to use environment variables.

func ExactArgs added in v0.0.6

func ExactArgs(cmd *cobra.Command, args []string, l int)

ExactArgs fatals if args does not equal l.

func ExpectDependency added in v0.0.37

func ExpectDependency(logger *logrusx.Logger, dependencies ...interface{})

ExpectDependency expects every dependency to be not nil or it fatals.

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 MinArgs

func MinArgs(cmd *cobra.Command, args []string, min int)

MinArgs fatals if args does not satisfy min.

func Must

func Must(err error, message string, args ...interface{})

Must fatals with the optional message if err is not nil.

func RangeArgs added in v0.0.6

func RangeArgs(cmd *cobra.Command, args []string, r []int)

RangeArgs fatals if args does not satisfy any of the lengths set in r.

func Version

func Version(gitTag, gitHash, buildTime *string) *cobra.Command

Version returns a *cobra.Command that handles the `version` command.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL