Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple short options are not detected with IgnoreUnknown flag. #399

Open
ghost opened this issue Aug 14, 2023 · 0 comments
Open

Multiple short options are not detected with IgnoreUnknown flag. #399

ghost opened this issue Aug 14, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Aug 14, 2023

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.

@ghost ghost changed the title Short options are not working with IgnoreUnknown option Stacked short options are not working with IgnoreUnknown option Aug 17, 2023
@ghost ghost changed the title Stacked short options are not working with IgnoreUnknown option Stacked short options are not working with IgnoreUnknown flag Aug 17, 2023
@ghost ghost changed the title Stacked short options are not working with IgnoreUnknown flag Multiple short options are not detected with IgnoreUnknown flag. Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants