Documentation
¶
Index ¶
- func Execute()
- func RootSet(options ...Option)
- type Command
- type FlagOption
- type FlagSet
- type Option
- func Aliases(aliases ...string) Option
- func Deprecated(deprecated string) Option
- func Description(short string, long ...string) Option
- func ExactArgs(n int) Option
- func Example(example string) Option
- func Flags(sets ...FlagOption) Option
- func GroupID(groupID string) Option
- func Hidden(hide bool) Option
- func MaximumNArgs(n int) Option
- func MinimumNArgs(n int) Option
- func Options(options ...Option) Option
- func PersistentFlags(sets ...FlagOption) Option
- func PersistentPostRun[T RunFunc](fn T) Option
- func PersistentPreRun[T RunFunc](fn T) Option
- func PositionalArgs(fn func(cmd *Command, args []string) error) Option
- func PostRun[T RunFunc](fn T) Option
- func PreRun[T RunFunc](fn T) Option
- func RangeArgs(min, max int) Option
- func Run[T RunFunc](fn T) Option
- func SuggestFor(suggestFor ...string) Option
- func Use(use string, aliases ...string) Option
- type RunFunc
- type VarT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
func AddCommand ¶
type FlagOption ¶
type FlagOption func(*FlagSet) // FlagOption flag option
type Option ¶
type Option func(*Command) // Option option
func Deprecated ¶
Deprecated defines, if this command is deprecated and should print this string when used.
func Description ¶
Description
Short is the short description shown in the 'help' output. Long is the long message shown in the 'help <this-command>' output.
func Flags ¶
func Flags(sets ...FlagOption) Option
Flags returns the complete FlagSet that applies to this command (local and persistent declared here and by all parents).
func GroupID ¶
The group id under which this subcommand is grouped in the 'help' output of its parent.
func MaximumNArgs ¶
MaximumNArgs returns an error if there are more than N args.
func MinimumNArgs ¶
MinimumNArgs returns an error if there is not at least N args.
func PersistentFlags ¶
func PersistentFlags(sets ...FlagOption) Option
PersistentFlags returns the persistent FlagSet specifically set in the current command.
func PersistentPostRun ¶
PersistentPostRun persistent post run the command
func PersistentPreRun ¶
PersistentPreRun persistent pre run the command
func PositionalArgs ¶
Expected arguments
func SuggestFor ¶
SuggestFor is an array of command names for which this command will be suggested - similar to aliases but only suggests.
func Use ¶
Use is the one-line usage message. Recommended syntax is as follows:
[ ] identifies an optional argument. Arguments that are not enclosed in brackets are required.
... indicates that you can specify multiple values for the previous argument.
| indicates mutually exclusive information. You can use the argument to the left of the separator or the
argument to the right of the separator. You cannot use both arguments in a single use of the command.
{ } delimits a set of mutually exclusive arguments when one of the arguments is required. If the arguments are
optional, they are enclosed in brackets ([ ]).
Example: add [-F file | -D dir]... [-f format] profile
Aliases is an array of aliases that can be used instead of the first word in Use.
type RunFunc ¶
type RunFunc interface {
func() | func(args []string) | func(*Command, []string) | func(*Command) |
func() error | func(args []string) error | func(*Command, []string) error | func(*Command) error
}
RunFunc cobra run
type VarT ¶
type VarT interface {
int8 |
int16 | uint8 | uint16 | uint32 | uint64 |
bool | string | int | int32 | int64 | uint | float32 | float64 | time.Duration | net.IP |
[]bool | []string | []int | []int32 | []int64 | []uint | []float32 | []float64 | []time.Duration | []net.IP
}
VarT is the type of the variable to be added to the flag set.