Documentation ¶
Overview ¶
Package parser implements compatibility with the "github.com/jessevdk/go-flags" package
Index ¶
- func AllFlags[T any]() []meta.Flag
- func AllPositionals[T any]() []meta.Positional
- func IsHelp(err error) bool
- func IsUnknownFlag(err error) bool
- func NewFlag(option *flags.Option) (flag meta.Flag)
- func NewPositional(arg *flags.Arg, field reflect.StructField) (pos meta.Positional)
- type Config
- type Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllPositionals ¶
func AllPositionals[T any]() []meta.Positional
func IsUnknownFlag ¶
IsUnknownFlag checks if err indicates an unknown flag
func NewPositional ¶
func NewPositional(arg *flags.Arg, field reflect.StructField) (pos meta.Positional)
NewPositional creates a new Positional from a flag argument
Types ¶
type Config ¶
type Config struct { // IncludeUnknown causes unknown flags to be parsed as positional arguments. // When IncludeUnknown in false, unknown flags produce an error instead. IncludeUnknown bool }
Config represents configuration for the parser for a command
func (Config) NewCommandParser ¶
NewCommandParser checks if command represents a valid command and, when this is the case, creates a new parser for it with the config provided in ParserConfig.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parse represents a parser for arguments.
It is internally backed by the "github.com/jessevdk/go-flags" package.
func NewArgumentsParser ¶
NewArgumentsParser creates a new parser fo parse a set of arguments
func (Parser) ParseArgs ¶
ParseArgs parses arguments for this parser.
The returned error may be nil, a help error, an unknown flag error or otherwise. See also IsHelp, IsUnknownFlag.
func (Parser) Positionals ¶
func (p Parser) Positionals() []meta.Positional