jessevdk/go-flags

Multiple short options are not detected with `IgnoreUnknown` flag.

d1nch8g opened this issue · 0 comments

Stacked short options are not recognized after first unknown option (even with flag IgnoreUnknown).

Following code sample:

package main

import (
	"fmt"

	"github.com/jessevdk/go-flags"
)

var first struct {
	Query bool `short:"Q" long:"query"`
}

var second struct {
	Quick bool `short:"q" long:"quick"`
}

func main() {
	flags.NewParser(&first, flags.IgnoreUnknown).Parse()
	fmt.Println(first)

	flags.NewParser(&second, flags.IgnoreUnknown).Parse()
	fmt.Println(second)
}

Produces results:

 > go run . -Qq
{true}
{false}
 > go run . -qQ  
{false}
{true}
 > go run . -Q -q
{true}
{true}

I expect true&true in each run, but results are different.