mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
bump(spf13/pflag):370c3171201099fa6b466db45c8a032cbce33d8d
This commit is contained in:
parent
4c87805870
commit
f943701a74
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -235,7 +235,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/spf13/pflag",
|
||||
"Rev": "f82776d6cc998e3c026baef7b24409ff49fe5c8d"
|
||||
"Rev": "370c3171201099fa6b466db45c8a032cbce33d8d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/stretchr/objx",
|
||||
|
5
Godeps/_workspace/src/github.com/spf13/pflag/flag.go
generated
vendored
5
Godeps/_workspace/src/github.com/spf13/pflag/flag.go
generated
vendored
@ -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)
|
||||
}
|
||||
|
38
Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go
generated
vendored
38
Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go
generated
vendored
@ -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])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user