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

Fix multiple short options with IgnoreUnknown option #400

Closed
wants to merge 2 commits into from
Closed

Fix multiple short options with IgnoreUnknown option #400

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 19, 2023

Related to Issue:

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)
}

Before fix:

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

After fix:

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

@ghost ghost changed the title Fix for not working stacked options with IgnoreUnknown option. Fix multiple short options with IgnoreUnknown option. Nov 19, 2023
@ghost ghost changed the title Fix multiple short options with IgnoreUnknown option. Fix multiple short options with IgnoreUnknown option Nov 19, 2023
@ghost ghost closed this by deleting the head repository May 13, 2024
This pull request was closed.
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

Successfully merging this pull request may close these issues.

1 participant