Documentation ¶
Overview ¶
Package argo is a library for parsing command line arguments.
Index ¶
- type ArgParser
- func (parser *ArgParser) ArgsAsFloats() []float64
- func (parser *ArgParser) ArgsAsInts() []int
- func (parser *ArgParser) CommandName() string
- func (parser *ArgParser) CommandParser() *ArgParser
- func (parser *ArgParser) Count(name string) int
- func (parser *ArgParser) CountArgs() int
- func (parser *ArgParser) EnableHelpCommand(enable bool)
- func (parser *ArgParser) ExitWithHelptext()
- func (parser *ArgParser) ExitWithVersion()
- func (parser *ArgParser) FloatValue(name string) float64
- func (parser *ArgParser) FloatValues(name string) []float64
- func (parser *ArgParser) Found(name string) bool
- func (parser *ArgParser) HasArgs() bool
- func (parser *ArgParser) HasCommand() bool
- func (parser *ArgParser) IntValue(name string) int
- func (parser *ArgParser) IntValues(name string) []int
- func (parser *ArgParser) NewCommand(name string) *ArgParser
- func (parser *ArgParser) NewFlag(name string)
- func (parser *ArgParser) NewFloatOption(name string, fallback float64)
- func (parser *ArgParser) NewIntOption(name string, fallback int)
- func (parser *ArgParser) NewStringOption(name string, fallback string)
- func (parser *ArgParser) Parse()
- func (parser *ArgParser) ParseArgs(args []string)
- func (parser *ArgParser) String() string
- func (parser *ArgParser) StringValue(name string) string
- func (parser *ArgParser) StringValues(name string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgParser ¶
type ArgParser struct { // Help text for the application or command. Helptext string // The application's version number. Version string // Stores positional arguments. Args []string // Stores the callback function for a command parser. Callback func(string, *ArgParser) // contains filtered or unexported fields }
An ArgParser instance stores registered options and commands.
func (*ArgParser) ArgsAsFloats ¶
ArgsAsFloats attempts to parse and return the positional arguments as a slice of floats. Exits with an error message if any of the arguments cannot be parsed as a float.
func (*ArgParser) ArgsAsInts ¶
ArgsAsInts attempts to parse and return the positional arguments as a slice of integers. Exits with an error message if any of the arguments cannot be parsed as an integer.
func (*ArgParser) CommandName ¶
CommandName returns the command name, if the parser has found a command.
func (*ArgParser) CommandParser ¶
CommandParser returns the command's parser instance, if the parser has found a command.
func (*ArgParser) EnableHelpCommand ¶
This boolean switch toggles support for an automatic `help` command which prints subcommand helptext. The value defaults to `false` but gets toggled automatically to true whenever a command is registered. You can use this method to disable the feature if required.
func (*ArgParser) ExitWithHelptext ¶
func (parser *ArgParser) ExitWithHelptext()
ExitWithHelptext prints the parser's help text, then exits.
func (*ArgParser) ExitWithVersion ¶
func (parser *ArgParser) ExitWithVersion()
ExitWithVersion prints the parser's version string, then exits.
func (*ArgParser) FloatValue ¶
FloatValue returns the value of the specified float-valued option.
func (*ArgParser) FloatValues ¶
FloatValues returns the specified float-valued option's list of values.
func (*ArgParser) HasArgs ¶
HasArgs returns true if the parser has found one or more positional arguments.
func (*ArgParser) HasCommand ¶
HasCommand returns true if the parser has found a command.
func (*ArgParser) IntValues ¶
IntValues returns the specified integer-valued option's list of values.
func (*ArgParser) NewCommand ¶
NewCommand registers a new command. The `name` parameter accepts an unlimited number of space- separated aliases for the command. Returns the command's `ArgParser` instance.
func (*ArgParser) NewFlag ¶
NewFlag registers a new flag. The `name` parameter accepts an unlimited number of space-separated aliases and single-character shortcuts.
func (*ArgParser) NewFloatOption ¶
NewFloatOption registers a new float-valued option. The `name` parameter accepts an unlimited number of space-separated aliases and single-character shortcuts. The `fallback` parameter specifies the option's default value.
func (*ArgParser) NewIntOption ¶
NewIntOption registers a new integer-valued option. The `name` parameter accepts an unlimited number of space-separated aliases and single-character shortcuts. The `fallback` parameter specifies the option's default value.
func (*ArgParser) NewStringOption ¶
NewStringOption registers a new string-valued option. The `name` parameter accepts an unlimited number of space-separated aliases and single-character shortcuts. The `fallback` parameter specifies the option's default value.
func (*ArgParser) Parse ¶
func (parser *ArgParser) Parse()
Parse parses the application's command line arguments.
func (*ArgParser) StringValue ¶
StringValue returns the value of the specified string-valued option.
func (*ArgParser) StringValues ¶
StringValues returns the specified string-valued option's list of values.