cli

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ShellCompDirectiveNoFileComp = cobra.ShellCompDirectiveNoFileComp
)

Variables

This section is empty.

Functions

func Apply

func Apply(c *Command, cmdOpts ...Option)

func CheckErr

func CheckErr(msg interface{})

CheckErr prints the msg with the prefix 'Error:' and exits with error code 1. If the msg is nil, it does nothing.

func CheckExit

func CheckExit(err error, printStack ...bool)

func SetDebug

func SetDebug(debug bool)

Types

type AnyFlag

type AnyFlag pflag.FlagSet

func StructFlag

func StructFlag(fs *pflag.FlagSet) *AnyFlag

func (*AnyFlag) VarP

func (af *AnyFlag) VarP(name, shorthand string, value interface{}, usage string)

type Command

type Command struct{ cobra.Command }

func New

func New(cmdOpts ...Option) *Command

func (*Command) AddCommand

func (c *Command) AddCommand(commands ...*Command)

func (*Command) AddTo

func (c *Command) AddTo(parent *Command) *Command

func (*Command) Execute

func (c *Command) Execute(ctx context.Context)

type FlagSet

type FlagSet = pflag.FlagSet

type Option

type Option interface {
	Apply(c *Command)
}

func Alias

func Alias(alias ...string) Option

func ArgAliases

func ArgAliases(alias ...string) Option

func Args

func Args(args PositionalArgs) Option

func Comment

func Comment(short string, long ...string) Option

func DisableAutoGenTag

func DisableAutoGenTag(disabled ...bool) Option

func DisableFlagParsing

func DisableFlagParsing(disabled ...bool) Option

func DisableFlagsInUseLine

func DisableFlagsInUseLine(disabled ...bool) Option

func DisableSuggestions

func DisableSuggestions(disabled ...bool) Option

func ExactArgs

func ExactArgs(n int) Option

func ExactValidArgs

func ExactValidArgs(n int) Option

func Flags

func Flags(appFlag func(fs *FlagSet)) Option

func Group

func Group(opts ...Option) Option

func HelpCommand

func HelpCommand() Option

func Hidden

func Hidden(hidden ...bool) Option

func Long

func Long(long ...string) Option

func PersistentFlags

func PersistentFlags(appFlag func(fs *FlagSet)) Option

func PersistentPostRun

func PersistentPostRun(run Runnable) Option

func PersistentPreRun

func PersistentPreRun(run Runnable) Option

func PostRun

func PostRun(run Runnable) Option

func PreRun

func PreRun(run Runnable) Option

func Run

func Run(run Runnable) Option

func StructFlags

func StructFlags(appFlag func(fs *AnyFlag)) Option

func SubCommand

func SubCommand(commands ...*Command) Option

func Use

func Use(use string, alias ...string) Option

func ValidArgs

func ValidArgs(validArgs ...string) Option

func ValidArgsFunction

func ValidArgsFunction(validFunc func(c *Command, args []string, toComplete string) ([]string, ShellCompDirective)) Option

func Version

func Version(version string) Option

type OptionApply

type OptionApply func(c *Command)

func (OptionApply) Apply

func (opt OptionApply) Apply(c *Command)

type PositionalArgs

type PositionalArgs = cobra.PositionalArgs

type Runnable

type Runnable func(c *Command, args []string)

type ShellCompDirective

type ShellCompDirective = cobra.ShellCompDirective

Jump to

Keyboard shortcuts

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