Joined boolean flags w/o positional arguments incorrectly parsed #1

Open
wdscxsj opened this Issue Feb 27, 2017 · 0 comments

Comments

Projects
None yet
1 participant

wdscxsj commented Feb 27, 2017

package main

import (
	"fmt"
	"github.com/juju/gnuflag"
)

func main() {
	var a, b bool
	gnuflag.BoolVar(&a, "a", false, "1st bool")
	gnuflag.BoolVar(&b, "b", false, "2nd bool")
	gnuflag.CommandLine.Parse(true, []string{"-ab"}) // WRONG: true false
	// gnuflag.CommandLine.Parse(true, []string{"-ab", ""}) // correct: true true
	fmt.Println(a, b)
}

The correct output should be true true, I suppose?

If multiple boolean flags are joined, e.g. -abcdefgh, only a is set to true. -abcdefgh anything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment