util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultErrorExitCode = 1
)
View Source
const (
	RecommendedHomeDir = ".grape"
)

Variables

View Source
var ErrExit = fmt.Errorf("exit")

Functions

func BehaviorOnFatal

func BehaviorOnFatal(f func(string, int))

func CheckErr

func CheckErr(err error)

func CombineRequestErr

func CombineRequestErr(resp gorequest.Response, body string, errs []error) error

func DefaultBehaviorOnFatal

func DefaultBehaviorOnFatal()

func GetFlagBool

func GetFlagBool(cmd *cobra.Command, flag string) bool

func GetFlagDuration

func GetFlagDuration(cmd *cobra.Command, flag string) time.Duration

func GetFlagInt

func GetFlagInt(cmd *cobra.Command, flag string) int

Assumes the flag has a default value.

func GetFlagInt64

func GetFlagInt64(cmd *cobra.Command, flag string) int64

Assumes the flag has a default value.

func GetFlagString

func GetFlagString(cmd *cobra.Command, flag string) string

func GetFlagStringArray

func GetFlagStringArray(cmd *cobra.Command, flag string) []string

GetFlagStringArray can be used to accept multiple argument with flag repetition (e.g. -f arg1 -f arg2 ...)

func GetFlagStringSlice

func GetFlagStringSlice(cmd *cobra.Command, flag string) []string

GetFlagStringSlice can be used to accept multiple argument with flag repetition (e.g. -f arg1,arg2 -f arg3 ...)

func GetWideFlag

func GetWideFlag(cmd *cobra.Command) bool

GetWideFlag is used to determine if "-o wide" is used

func IsFilenameEmpty

func IsFilenameEmpty(filenames []string) bool

func StandardErrorMessage

func StandardErrorMessage(err error) (string, bool)

func UsageErrorf

func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error

Types

type Factory

type Factory struct {
	Server   string
	Timeout  int
	Username string
	Password string
	Cool     bool
	// contains filtered or unexported fields
}

func NewFactory

func NewFactory() Factory

func (*Factory) Auth

func (f *Factory) Auth() string

func (*Factory) BindExternalFlags

func (f *Factory) BindExternalFlags(flags *pflag.FlagSet)

func (*Factory) BindFlags

func (f *Factory) BindFlags(flags *pflag.FlagSet)

func (*Factory) Command

func (f *Factory) Command() string

TODO: We need to filter out stuff like secrets.

func (*Factory) FlagSet

func (f *Factory) FlagSet() *pflag.FlagSet

func (*Factory) Gorequest

func (f *Factory) Gorequest() *gorequest.SuperAgent

Jump to

Keyboard shortcuts

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