~sircmpwn/getopt

23622cc906b37a74408b0bec01655be519a63554 — Wolf 1 year, 9 months ago daaf127
Allow parsing of flags from array
1 files changed, 10 insertions(+), 3 deletions(-)

M flagset.go
M flagset.go => flagset.go +10 -3
@@ 134,11 134,11 @@ func (set *FlagSet) Parsed() bool {
	return set.parsed
}

// Parse parses the command-line flags from os.Args. Must be called
// ParseSlice parses the command-line flags from args. Must be called
// after all flags are defined and before flags are accessed by the
// program.
func (set *FlagSet) Parse() (err error) {
	err = set.parse(os.Args)
func (set *FlagSet) ParseSlice(args []string) (err error) {
	err = set.parse(args)
	if err != nil {
		switch set.errorHandling {
		case flag.PanicOnError:


@@ 151,6 151,13 @@ func (set *FlagSet) Parse() (err error) {
	return
}

// Parse parses the command-line flags from os.Args. Must be called
// after all flags are defined and before flags are accessed by the
// program.
func (set *FlagSet) Parse() error {
	return set.ParseSlice(os.Args)
}

// ErrorHandling returns the error handling behavior of the flag set.
func (set *FlagSet) ErrorHandling() flag.ErrorHandling {
	return set.errorHandling