goNixArgParser

package
v1.10.13 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT, MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToSlice

func StringToSlice(input string) []string

Types

type Arg

type Arg struct {
	Text string
	Type ArgType
}

func NewArg

func NewArg(text string, argType ArgType) *Arg

type ArgType

type ArgType int
const (
	UndetermArg ArgType = iota
	CommandArg
	FlagArg
	ValueArg
	UndefFlagArg
	UndefFlagValueArg
	AmbiguousFlagArg
	AmbiguousFlagValueArg
	RestSignArg
	RestArg
	GroupSepArg
)

type Command

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

func NewCommand

func NewCommand(
	names []string,
	summary, mergeFlagPrefix string,
	restsSigns, groupSeps, undefFlagPrefixes []string,
) *Command

func NewSimpleCommand

func NewSimpleCommand(name, summary string, aliasNames ...string) *Command

func (*Command) GetHelp

func (c *Command) GetHelp() []byte

func (*Command) GetSubCommand

func (c *Command) GetSubCommand(name string) *Command

func (*Command) Name

func (c *Command) Name() (name string)

func (*Command) Names added in v1.1.0

func (c *Command) Names() []string

func (*Command) NewSimpleSubCommand

func (c *Command) NewSimpleSubCommand(name, summary string, aliasNames ...string) *Command

func (*Command) NewSubCommand

func (c *Command) NewSubCommand(
	names []string,
	summary, mergeFlagPrefix string,
	restsSigns, groupSeps, undefFlagPrefixes []string,
) *Command

func (*Command) Options added in v1.1.0

func (c *Command) Options() *OptionSet

func (*Command) Parse

func (c *Command) Parse(initArgs, initConfigs []string) *ParseResult

func (*Command) ParseGroups

func (c *Command) ParseGroups(initArgs, initConfigs []string) (results []*ParseResult)

func (*Command) PrintHelp

func (c *Command) PrintHelp()

func (*Command) SubCommands

func (c *Command) SubCommands() []*Command

func (*Command) Summary

func (c *Command) Summary() string

type Flag

type Flag struct {
	Name string
	// contains filtered or unexported fields
}

func NewFlag

func NewFlag(name string, prefixMatchLen int, canMerge, canFollowAssign, canConcatAssign bool, assignSigns []string) *Flag

func NewSimpleFlag

func NewSimpleFlag(name string) *Flag

func NewSimpleFlags

func NewSimpleFlags(names []string) []*Flag

type Option

type Option struct {
	Key           string
	Summary       string
	Description   string
	Flags         []*Flag
	AcceptValue   bool
	MultiValues   bool
	OverridePrev  bool
	Delimiters    []rune
	UniqueValues  bool
	EnvVars       []string
	DefaultValues []string
}

func NewFlagOption added in v1.8.0

func NewFlagOption(key, flag, envVar, summary string) Option

func NewFlagValueOption added in v1.8.0

func NewFlagValueOption(key, flag, envVar, defaultValue, summary string) Option

func NewFlagValuesOption added in v1.8.0

func NewFlagValuesOption(key, flag, envVar string, defaultValues []string, summary string) Option

func NewFlagsOption added in v1.8.0

func NewFlagsOption(key string, flags []string, envVar, summary string) Option

func NewFlagsValueOption added in v1.8.0

func NewFlagsValueOption(key string, flags []string, envVar, defaultValue, summary string) Option

func NewFlagsValuesOption added in v1.8.0

func NewFlagsValuesOption(key string, flags []string, envVar string, defaultValues []string, summary string) Option

func (*Option) GetHelp

func (opt *Option) GetHelp() []byte

type OptionSet

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

func NewOptionSet

func NewOptionSet(
	mergeFlagPrefix string,
	restsSigns []string,
	groupSeps []string,
	undefFlagPrefixes []string,
) *OptionSet

func NewSimpleOptionSet

func NewSimpleOptionSet() *OptionSet

func (*OptionSet) Add added in v1.8.0

func (s *OptionSet) Add(opt Option) error

func (*OptionSet) AddFlag

func (s *OptionSet) AddFlag(key, flag, envVar, summary string) error

func (*OptionSet) AddFlagValue

func (s *OptionSet) AddFlagValue(key, flag, envVar, defaultValue, summary string) error

func (*OptionSet) AddFlagValues

func (s *OptionSet) AddFlagValues(key, flag, envVar string, defaultValues []string, summary string) error

func (*OptionSet) AddFlags

func (s *OptionSet) AddFlags(key string, flags []string, envVar, summary string) error

func (*OptionSet) AddFlagsValue

func (s *OptionSet) AddFlagsValue(key string, flags []string, envVar, defaultValue, summary string) error

func (*OptionSet) AddFlagsValues

func (s *OptionSet) AddFlagsValues(key string, flags []string, envVar string, defaultValues []string, summary string) error

func (*OptionSet) GetHelp

func (s *OptionSet) GetHelp() []byte

func (*OptionSet) GroupSeps

func (s *OptionSet) GroupSeps() []string

func (*OptionSet) MergeFlagPrefix added in v1.1.0

func (s *OptionSet) MergeFlagPrefix() string

func (*OptionSet) Parse

func (s *OptionSet) Parse(initArgs, initConfigs []string) *ParseResult

func (*OptionSet) ParseGroups

func (s *OptionSet) ParseGroups(initArgs, initConfigs []string) []*ParseResult

func (*OptionSet) RestsSigns

func (s *OptionSet) RestsSigns() []string

func (*OptionSet) UndefFlagPrefixes added in v1.6.1

func (s *OptionSet) UndefFlagPrefixes() []string

type ParseResult

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

func (*ParseResult) GetAmbigus added in v1.8.0

func (r *ParseResult) GetAmbigus() []string

func (*ParseResult) GetBool

func (r *ParseResult) GetBool(key string) (value bool, found bool)

func (*ParseResult) GetBools

func (r *ParseResult) GetBools(key string) (values []bool, found bool)

func (*ParseResult) GetCommands

func (r *ParseResult) GetCommands() []string

///////////////////////////// commands ////////////////////////////

func (*ParseResult) GetFloat64

func (r *ParseResult) GetFloat64(key string) (value float64, found bool)

func (*ParseResult) GetFloat64s

func (r *ParseResult) GetFloat64s(key string) (values []float64, found bool)

func (*ParseResult) GetInt

func (r *ParseResult) GetInt(key string) (value int, found bool)

func (*ParseResult) GetInt64

func (r *ParseResult) GetInt64(key string) (value int64, found bool)

func (*ParseResult) GetInt64s

func (r *ParseResult) GetInt64s(key string) (values []int64, found bool)

func (*ParseResult) GetInts

func (r *ParseResult) GetInts(key string) (values []int, found bool)

func (*ParseResult) GetRests

func (r *ParseResult) GetRests() (rests []string)

func (*ParseResult) GetString

func (r *ParseResult) GetString(key string) (value string, found bool)

func (*ParseResult) GetStrings

func (r *ParseResult) GetStrings(key string) (values []string, found bool)

///////////////////////////// get multi values ////////////////////////////

func (*ParseResult) GetUint64

func (r *ParseResult) GetUint64(key string) (value uint64, found bool)

func (*ParseResult) GetUint64s

func (r *ParseResult) GetUint64s(key string) (values []uint64, found bool)

func (*ParseResult) GetUndefs added in v1.6.1

func (r *ParseResult) GetUndefs() []string

func (*ParseResult) HasAmbigu added in v1.8.0

func (r *ParseResult) HasAmbigu() bool

///////////////////////////// ambigus ////////////////////////////

func (*ParseResult) HasConfigKey

func (r *ParseResult) HasConfigKey(key string) bool

func (*ParseResult) HasConfigValue

func (r *ParseResult) HasConfigValue(key string) bool

func (*ParseResult) HasDefaultKey

func (r *ParseResult) HasDefaultKey(key string) bool

func (*ParseResult) HasDefaultValue

func (r *ParseResult) HasDefaultValue(key string) bool

func (*ParseResult) HasEnvKey

func (r *ParseResult) HasEnvKey(key string) bool

func (*ParseResult) HasEnvValue

func (r *ParseResult) HasEnvValue(key string) bool

func (*ParseResult) HasFlagKey

func (r *ParseResult) HasFlagKey(key string) bool

func (*ParseResult) HasFlagValue

func (r *ParseResult) HasFlagValue(key string) bool

func (*ParseResult) HasKey

func (r *ParseResult) HasKey(key string) bool

func (*ParseResult) HasUndef added in v1.6.1

func (r *ParseResult) HasUndef() bool

///////////////////////////// undefs ////////////////////////////

func (*ParseResult) HasValue

func (r *ParseResult) HasValue(key string) bool

func (*ParseResult) SetConfig

func (r *ParseResult) SetConfig(key, value string)

///////////////////////////// set configs ////////////////////////////

func (*ParseResult) SetConfigs

func (r *ParseResult) SetConfigs(key string, values []string)

Jump to

Keyboard shortcuts

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