Documentation ¶
Index ¶
- Constants
- Variables
- func FileIsReadable(args ...string) bool
- func Translate(key string) string
- type Argument
- func (a *Argument) Describe() string
- func (a *Argument) GetDefaultValue() []string
- func (a *Argument) GetName() string
- func (a *Argument) GetValidationMessage(value ...string) string
- func (a *Argument) GetValue() []string
- func (a *Argument) HasDefaultValue() bool
- func (a *Argument) HasValidation() bool
- func (a *Argument) IsMultiple() bool
- func (a *Argument) Multiple(m bool) *Argument
- func (a *Argument) SetDefaultValue(value string) *Argument
- func (a *Argument) SetName(name string) *Argument
- func (a *Argument) SetOption(o *Option) *Argument
- func (a *Argument) SetValidation(callable validationFunc, message *string) *Argument
- func (a *Argument) SetValue(value ...string) (*Argument, error)
- func (a *Argument) Validates(args ...string) bool
- type Arguments
- type Command
- func (c *Command) Build(name string, handler handlerFunc, options ...*Option) (*Command, error)
- func (c *Command) Description() string
- func (c *Command) GetDescription() string
- func (c *Command) GetHandler() handlerFunc
- func (c *Command) GetName() string
- func (c *Command) GetShortDescription() string
- func (c *Command) Name() string
- func (c *Command) SetDescription(longDescription string) *Command
- func (c *Command) SetHandler(handler handlerFunc) *Command
- func (c *Command) SetName(name string) (*Command, error)
- func (c *Command) ShortDescription() string
- type CommandInterface
- type Describable
- type GetOpt
- func (g *GetOpt) AddCommand(command CommandInterface) (*GetOpt, error)
- func (g *GetOpt) AddCommands(commands ...CommandInterface) (*GetOpt, error)
- func (g *GetOpt) Count() int
- func (g *GetOpt) Get(setting string) string
- func (g *GetOpt) GetCommand(name string) CommandInterface
- func (g *GetOpt) GetCommands() map[string]CommandInterface
- func (g *GetOpt) GetHelp() HelpInterface
- func (g *GetOpt) GetHelpText(data map[string]string) string
- func (g *GetOpt) GetOperand(index string) []string
- func (g *GetOpt) GetOperands() []string
- func (g *GetOpt) GetOptionString(name string) string
- func (g *GetOpt) GetOptionValue(name string) []string
- func (g *GetOpt) GetOptions() map[string][]string
- func (g *GetOpt) HasCommands() bool
- func (g *GetOpt) Iter() map[string][]string
- func (g *GetOpt) NextOperand() *Operand
- func (g *GetOpt) Parse(arguments string)
- func (g *GetOpt) Process(args ...string) error
- func (g *GetOpt) Set(setting string, value string) *GetOpt
- func (g *GetOpt) SetHelp(help HelpInterface) *GetOpt
- func (g *GetOpt) SetHelpLang(language string) bool
- func (g *GetOpt) SetLang(language string) bool
- func (g *GetOpt) SetScriptName(scriptName string) *GetOpt
- type Help
- func (h *Help) GetCommandsTemplate() string
- func (h *Help) GetOptionsTemplate() string
- func (h *Help) GetText(key string) string
- func (h *Help) GetUsageTemplate() string
- func (h *Help) Render(getOpt *GetOpt, data map[string]string) string
- func (h *Help) Set(setting string, value string) *Help
- func (h *Help) SetCommandsTemplate(commandsTemplate string) *Help
- func (h *Help) SetOptionsTemplate(optionsTemplate string) *Help
- func (h *Help) SetTexts(texts map[string]string) *Help
- func (h *Help) SetUsageTemplate(usageTemplate string) *Help
- type HelpInterface
- type Operand
- func (o *Operand) GetDescription() string
- func (o *Operand) GetValue() []string
- func (o *Operand) IsRequired() bool
- func (o *Operand) Required(required bool) *Operand
- func (o *Operand) SetDescription(description string) *Operand
- func (o *Operand) SetValue(value ...string) (*Operand, error)
- func (o *Operand) String() string
- func (o *Operand) Value() []string
- type Option
- func (o *Option) Describe() string
- func (o *Option) GetArgument() *Argument
- func (o *Option) GetDescription() string
- func (o *Option) GetLong() string
- func (o *Option) GetMode() string
- func (o *Option) GetName() string
- func (o *Option) GetShort() rune
- func (o *Option) GetValue() []string
- func (o *Option) Long() string
- func (o *Option) Mode() string
- func (o *Option) SetArgument(arg *Argument) (*Option, error)
- func (o *Option) SetArgumentName(name string) *Option
- func (o *Option) SetDefaultValue(value string) *Option
- func (o *Option) SetDescription(description string) *Option
- func (o *Option) SetLong(long string) (*Option, error)
- func (o *Option) SetMode(mode string) (*Option, error)
- func (o *Option) SetShort(short rune) (*Option, error)
- func (o *Option) SetValidation(validation validationFunc, message *string) *Option
- func (o *Option) SetValue(value ...string) (*Option, error)
- func (o *Option) Short() rune
- func (o *Option) String() string
- func (o *Option) Value() []string
- type OptionParser
- type Translator
- type WithOperands
- func (w *WithOperands) AddOperand(operand *Operand) (*WithOperands, error)
- func (w *WithOperands) AddOperands(operands ...*Operand) (*WithOperands, error)
- func (w *WithOperands) GetOperand(index interface{}) *Operand
- func (w *WithOperands) GetOperands() []*Operand
- func (w *WithOperands) HasOperands() bool
- type WithOptions
- func (w *WithOptions) AddOption(option *Option) (*WithOptions, error)
- func (w *WithOptions) AddOptionArray(s []string) (*WithOptions, error)
- func (w *WithOptions) AddOptionString(option string) (*WithOptions, error)
- func (w *WithOptions) AddOptions(options ...*Option) (*WithOptions, error)
- func (w *WithOptions) Conflicts(option *Option) bool
- func (w *WithOptions) GetOption(name string) *Option
- func (w *WithOptions) GetOptions() []*Option
- func (w *WithOptions) HasOptions() bool
Constants ¶
View Source
const DESCRIPTION = "description"
View Source
const HIDE_OPERANDS = "hideOperands"
View Source
const MAX_WIDTH = "maxWidth"
View Source
const MULTIPLE = 2
View Source
const MULTIPLE_ARGUMENT = ":multipleArg"
View Source
const NO_ARGUMENT = ":noArg"
View Source
const OPTIONAL = 0
View Source
const OPTIONAL_ARGUMENT = ":optionalArg"
View Source
const REQUIRED = 1
View Source
const REQUIRED_ARGUMENT = ":requiredArg"
View Source
const TRANSLATION_KEY = "operand"
Variables ¶
View Source
var SETTING_COMMAND_NAME = "scriptName"
View Source
var SETTING_DEFAULT_MODE = "defaultMode"
View Source
var SETTING_STRICT_OPERANDS = "strictOperands"
View Source
var SETTING_STRICT_OPTIONS = "strictOptions"
Functions ¶
func FileIsReadable ¶
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
func NewArgument ¶
func (*Argument) GetDefaultValue ¶
func (*Argument) GetValidationMessage ¶
func (*Argument) HasDefaultValue ¶
func (*Argument) HasValidation ¶
func (*Argument) IsMultiple ¶
func (*Argument) SetDefaultValue ¶
func (*Argument) SetValidation ¶
type Arguments ¶
type Arguments struct {
// contains filtered or unexported fields
}
func NewArguments ¶
func (*Arguments) FromString ¶
type Command ¶
type Command struct { WithOptions WithOperands // contains filtered or unexported fields }
func NewCommand ¶
func (*Command) Description ¶
func (*Command) GetDescription ¶
func (*Command) GetHandler ¶
func (c *Command) GetHandler() handlerFunc
func (*Command) GetShortDescription ¶
func (*Command) SetDescription ¶
func (*Command) SetHandler ¶
func (*Command) ShortDescription ¶
type CommandInterface ¶
type Describable ¶
type Describable interface {
Describe() string
}
type GetOpt ¶
type GetOpt struct { WithOperands WithOptions // contains filtered or unexported fields }
func (*GetOpt) AddCommand ¶
func (g *GetOpt) AddCommand(command CommandInterface) (*GetOpt, error)
func (*GetOpt) AddCommands ¶
func (g *GetOpt) AddCommands(commands ...CommandInterface) (*GetOpt, error)
func (*GetOpt) GetCommand ¶
func (g *GetOpt) GetCommand(name string) CommandInterface
func (*GetOpt) GetCommands ¶
func (g *GetOpt) GetCommands() map[string]CommandInterface
func (*GetOpt) GetHelp ¶
func (g *GetOpt) GetHelp() HelpInterface
func (*GetOpt) GetOperand ¶
func (*GetOpt) GetOperands ¶
func (*GetOpt) GetOptionString ¶
func (*GetOpt) GetOptionValue ¶
func (*GetOpt) GetOptions ¶
func (*GetOpt) HasCommands ¶
func (*GetOpt) NextOperand ¶
func (*GetOpt) SetHelp ¶
func (g *GetOpt) SetHelp(help HelpInterface) *GetOpt
func (*GetOpt) SetHelpLang ¶
func (*GetOpt) SetScriptName ¶
type Help ¶
type Help struct {
// contains filtered or unexported fields
}
func (*Help) GetCommandsTemplate ¶
func (*Help) GetOptionsTemplate ¶
func (*Help) GetUsageTemplate ¶
func (*Help) SetCommandsTemplate ¶
func (*Help) SetOptionsTemplate ¶
func (*Help) SetUsageTemplate ¶
type Operand ¶
type Operand struct { Argument // contains filtered or unexported fields }
func NewOperand ¶
func (*Operand) GetDescription ¶
func (*Operand) IsRequired ¶
func (*Operand) SetDescription ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func (*Option) GetArgument ¶
func (*Option) GetDescription ¶
func (*Option) SetArgumentName ¶
func (*Option) SetDefaultValue ¶
func (*Option) SetDescription ¶
func (*Option) SetValidation ¶
type OptionParser ¶
type OptionParser struct{}
func NewOptionParser ¶
func NewOptionParser(mode string) *OptionParser
func (*OptionParser) CompleteOptionArray ¶
func (o *OptionParser) CompleteOptionArray(row []string) []string
func (*OptionParser) ParseArray ¶
func (o *OptionParser) ParseArray(p []string) (*Option, error)
func (*OptionParser) ParseString ¶
func (o *OptionParser) ParseString(s string) ([]*Option, error)
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
func GetTranslator ¶
func GetTranslator() *Translator
func NewTranslator ¶
func NewTranslator(language string, asFallback ...bool) (*Translator, error)
func (*Translator) LoadTranslations ¶
func (t *Translator) LoadTranslations()
func (*Translator) SetLanguage ¶
func (t *Translator) SetLanguage(language string) bool
func (*Translator) Translate ¶
func (t *Translator) Translate(key string) string
type WithOperands ¶
type WithOperands struct {
// contains filtered or unexported fields
}
func (*WithOperands) AddOperand ¶
func (w *WithOperands) AddOperand(operand *Operand) (*WithOperands, error)
func (*WithOperands) AddOperands ¶
func (w *WithOperands) AddOperands(operands ...*Operand) (*WithOperands, error)
func (*WithOperands) GetOperand ¶
func (w *WithOperands) GetOperand(index interface{}) *Operand
func (*WithOperands) GetOperands ¶
func (w *WithOperands) GetOperands() []*Operand
func (*WithOperands) HasOperands ¶
func (w *WithOperands) HasOperands() bool
type WithOptions ¶
type WithOptions struct {
// contains filtered or unexported fields
}
func (*WithOptions) AddOption ¶
func (w *WithOptions) AddOption(option *Option) (*WithOptions, error)
func (*WithOptions) AddOptionArray ¶
func (w *WithOptions) AddOptionArray(s []string) (*WithOptions, error)
func (*WithOptions) AddOptionString ¶
func (w *WithOptions) AddOptionString(option string) (*WithOptions, error)
func (*WithOptions) AddOptions ¶
func (w *WithOptions) AddOptions(options ...*Option) (*WithOptions, error)
func (*WithOptions) Conflicts ¶
func (w *WithOptions) Conflicts(option *Option) bool
func (*WithOptions) GetOption ¶
func (w *WithOptions) GetOption(name string) *Option
func (*WithOptions) GetOptions ¶
func (w *WithOptions) GetOptions() []*Option
func (*WithOptions) HasOptions ¶
func (w *WithOptions) HasOptions() bool
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package errors implements functions to manipulate errors.
|
Package errors implements functions to manipulate errors. |
Click to show internal directories.
Click to hide internal directories.