cmdutil

package
v0.1.0-24-ga60fd7e Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCancel = errors.New("ErrCancel")

ErrCancel signals user-initiated cancellation

View Source
var ErrSilent = errors.New("ErrSilent")

ErrSilent is an error that triggers exit code 1 without any error messaging

Functions

func BoolVarP

func BoolVarP(p *bool, name, shorthand string, value bool, usage string) *pflag.Flag

BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.

func ExactArgs

func ExactArgs(n int, msg string) cobra.PositionalArgs

func Execute

func Execute(cmdFactory *cmdfactory.Factory, cmd *cobra.Command) errs.ExitCode

func FlagErrorWrap

func FlagErrorWrap(err error) error

FlagError returns a new FlagError that wraps the specified error.

func FlagErrorf

func FlagErrorf(format string, args ...interface{}) error

FlagErrorf returns a new FlagError that wraps an error produced by fmt.Errorf(format, args...).

func HasCommand

func HasCommand(cmd *cobra.Command, args []string) bool

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 IsUserCancellation(err error) bool

func MaxDirArgs

func MaxDirArgs(n int) cobra.PositionalArgs

func MinimumArgs

func MinimumArgs(n int, msg string) cobra.PositionalArgs

func MutuallyExclusive

func MutuallyExclusive(message string, conditions ...bool) error

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 NoArgsQuoteReminder

func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error

func RegisterFlag

func RegisterFlag(cmdline string, flag *pflag.Flag)

func StringVarP

func StringVarP(p *string, name, shorthand string, value string, usage string) *pflag.Flag

StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.

func VarPF

func VarPF(value pflag.Value, name, shorthand, usage string) *pflag.Flag

VarPF is like VarP, but returns the flag created

Types

type CmdOption

type CmdOption func(*cobra.Command)

func WithSubcmds

func WithSubcmds(subCmds ...*cobra.Command) CmdOption

WithSubcmds iterates over a list of instantiated *cobra.Command and adds to the parent.

type EnumFlag

type EnumFlag struct {
	Allowed []string
	Value   string
}

func NewEnumFlag

func NewEnumFlag(allowed []string, d string) *EnumFlag

NewEnumFlag give a list of allowed flag parameters, where the second argument is the default

func (*EnumFlag) Set

func (a *EnumFlag) Set(p string) error

func (*EnumFlag) String

func (a *EnumFlag) String() string

func (*EnumFlag) Type

func (a *EnumFlag) Type() string

type FlagError

type FlagError struct {
	// contains filtered or unexported fields
}

A *FlagError indicates an error processing command-line flags or other arguments. Such errors cause the application to display the usage message.

func (*FlagError) Error

func (fe *FlagError) Error() string

func (*FlagError) Unwrap

func (fe *FlagError) Unwrap() error

Jump to

Keyboard shortcuts

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