bump(spf13/pflag):370c3171201099fa6b466db45c8a032cbce33d8d

This commit is contained in:
Andy Goldstein 2015-02-18 09:27:35 -05:00
parent 4c87805870
commit f943701a74
3 changed files with 42 additions and 3 deletions

2
Godeps/Godeps.json generated
View File

@ -235,7 +235,7 @@
},
{
"ImportPath": "github.com/spf13/pflag",
"Rev": "f82776d6cc998e3c026baef7b24409ff49fe5c8d"
"Rev": "370c3171201099fa6b466db45c8a032cbce33d8d"
},
{
"ImportPath": "github.com/stretchr/objx",

View File

@ -543,6 +543,11 @@ func (f *FlagSet) parseArgs(args []string) (err error) {
if s[1] == '-' {
args, err = f.parseLongArg(s, args)
if len(s) == 2 {
// stop parsing after --
break
}
} else {
args, err = f.parseShortArg(s, args)
}

View File

@ -197,8 +197,8 @@ func TestShorthand(t *testing.T) {
notaflag,
}
f.SetOutput(ioutil.Discard)
if err := f.Parse(args); err == nil {
t.Error("--i-look-like-a-flag should throw an error")
if err := f.Parse(args); err != nil {
t.Error("expected no error, got ", err)
}
if !f.Parsed() {
t.Error("f.Parse() = false after Parse")
@ -356,3 +356,37 @@ func TestNoInterspersed(t *testing.T) {
t.Fatal("expected interspersed options/non-options to fail")
}
}
func TestTermination(t *testing.T) {
f := NewFlagSet("termination", ContinueOnError)
boolFlag := f.BoolP("bool", "l", false, "bool value")
if f.Parsed() {
t.Error("f.Parse() = true before Parse")
}
arg1 := "ls"
arg2 := "-l"
args := []string{
"--",
arg1,
arg2,
}
f.SetOutput(ioutil.Discard)
if err := f.Parse(args); err != nil {
t.Fatal("expected no error; got ", err)
}
if !f.Parsed() {
t.Error("f.Parse() = false after Parse")
}
if *boolFlag {
t.Error("expected boolFlag=false, got true")
}
if len(f.Args()) != 2 {
t.Errorf("expected 2 arguments, got %d: %v", len(f.Args()), f.Args())
}
if f.Args()[0] != arg1 {
t.Errorf("expected argument %q got %q", arg1, f.Args()[0])
}
if f.Args()[1] != arg2 {
t.Errorf("expected argument %q got %q", arg2, f.Args()[1])
}
}