Documentation ¶
Index ¶
- Variables
- func Parse(args []string, flagSet ...*FVSet) error
- func ToKebabCase(input string) string
- type Command
- func (c *Command) AddArg(name string, shortName string, description string, defaultValue interface{})
- func (c *Command) AddSubCommand(name string, description string) *Command
- func (c *Command) GetGlobalOptions() map[string]interface{}
- func (c *Command) GetOption(name string) *Option
- func (c *Command) GetSubCommand() string
- func (c *Command) GetSubCommandOptions() map[string]interface{}
- func (c *Command) Parse(args []string) ([]string, error)
- func (c *Command) Usage()
- type FVSet
- type FVSets
- type FlagUsage
- type Option
- type Usage
Constants ¶
This section is empty.
Variables ¶
View Source
var UsageTemplate, _ = template.New("Usage").Parse(`Usage:
{{if .ParentCommand }} {{.ParentCommand.Name}} {{end}} {{.Name}} [OPTIONS] [ARGS]
{{ if .Description }}
Description:
{{.Description}}
{{ end }}
{{ if .Args }}
Options:
{{range .Args}}
-{{.ShortName}}|--{{.LongName}} {{.OType}} {{.Description}} default:{{.DefaultValue}}
{{end}}
{{ end }}
{{ if .SubCommands }}
Sub Commands:
{{range .SubCommands}}
{{.Name}} {{.Description}}
{{end}}
{{end}}
`)
Functions ¶
func Parse ¶
Parse is used to parse command line arguments based on one or more flag sets. args represents the list of command line arguments. flagSet is a variable-length parameter that contains the flag sets to be parsed. If no flag set is provided, it throws a panic exception. If only one flag set is provided, it directly parses the arguments with that flag set. If multiple flag sets are provided, it attempts to match and parse based on the first argument in args. If no matching flag set is found, it returns an error.
func ToKebabCase ¶
Types ¶
type Command ¶
type Command struct { Name string Description string Args []*Option SubCommands []*Command ParentCommand *Command // contains filtered or unexported fields }
func NewCommand ¶
func (*Command) AddSubCommand ¶
func (*Command) GetGlobalOptions ¶
func (*Command) GetSubCommand ¶
func (*Command) GetSubCommandOptions ¶
type FVSet ¶
Click to show internal directories.
Click to hide internal directories.