Documentation ¶
Index ¶
- Variables
- func BoolVarP(p *bool, name, shorthand string, value bool, usage string) *pflag.Flag
- func ExactArgs(n int, msg string) cobra.PositionalArgs
- func Execute(cmdFactory *cmdfactory.Factory, cmd *cobra.Command) errs.ExitCode
- func FlagErrorWrap(err error) error
- func FlagErrorf(format string, args ...interface{}) error
- func HasCommand(cmd *cobra.Command, args []string) bool
- func HasFailed() bool
- func IsUserCancellation(err error) bool
- func MaxDirArgs(n int) cobra.PositionalArgs
- func MinimumArgs(n int, msg string) cobra.PositionalArgs
- func MutuallyExclusive(message string, conditions ...bool) error
- func NewCmd(cmdFactory *cmdfactory.Factory, cmdName string, opts ...CmdOption) (*cobra.Command, error)
- func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error
- func RegisterFlag(cmdline string, flag *pflag.Flag)
- func StringVarP(p *string, name, shorthand string, value string, usage string) *pflag.Flag
- func VarPF(value pflag.Value, name, shorthand, usage string) *pflag.Flag
- type CmdOption
- type EnumFlag
- type FlagError
Constants ¶
This section is empty.
Variables ¶
var ErrCancel = errors.New("ErrCancel")
ErrCancel signals user-initiated cancellation
var ErrSilent = errors.New("ErrSilent")
ErrSilent is an error that triggers exit code 1 without any error messaging
Functions ¶
func BoolVarP ¶
BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.
func FlagErrorWrap ¶
FlagError returns a new FlagError that wraps the specified error.
func FlagErrorf ¶
FlagErrorf returns a new FlagError that wraps an error produced by fmt.Errorf(format, args...).
func HasCommand ¶
HasCommand returns true if args resolve to a built-in command
func HasFailed ¶
func HasFailed() bool
HasFailed signals that the main process should exit with non-zero status
func IsUserCancellation ¶
func MaxDirArgs ¶
func MaxDirArgs(n int) cobra.PositionalArgs
func MinimumArgs ¶
func MinimumArgs(n int, msg string) cobra.PositionalArgs
func MutuallyExclusive ¶
func NewCmd ¶
func NewCmd(cmdFactory *cmdfactory.Factory, cmdName string, opts ...CmdOption) (*cobra.Command, error)
NewCmd generates a template `*cobra.Command` with sensible defaults and ensures consistency between all binaries within KraftKit.
func RegisterFlag ¶
func StringVarP ¶
StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.
Types ¶
type CmdOption ¶
func WithSubcmds ¶
WithSubcmds iterates over a list of instantiated *cobra.Command and adds to the parent.
type EnumFlag ¶
func NewEnumFlag ¶
NewEnumFlag give a list of allowed flag parameters, where the second argument is the default