gnuflag icon indicating copy to clipboard operation
gnuflag copied to clipboard

Joined boolean flags w/o positional arguments incorrectly parsed

Open wdscxsj opened this issue 8 years ago • 0 comments

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.

wdscxsj avatar Feb 27 '17 08:02 wdscxsj