update godep for github.com/spf13/pflag
This commit is contained in:
63
vendor/github.com/spf13/pflag/flag.go
generated
vendored
63
vendor/github.com/spf13/pflag/flag.go
generated
vendored
@@ -419,20 +419,36 @@ func (f *FlagSet) PrintDefaults() {
|
||||
fmt.Fprintf(f.out(), "%s", usages)
|
||||
}
|
||||
|
||||
// isZeroValue guesses whether the string represents the zero
|
||||
// value for a flag. It is not accurate but in practice works OK.
|
||||
func isZeroValue(value string) bool {
|
||||
switch value {
|
||||
case "false":
|
||||
return true
|
||||
case "<nil>":
|
||||
return true
|
||||
case "":
|
||||
return true
|
||||
case "0":
|
||||
return true
|
||||
// defaultIsZeroValue returns true if the default value for this flag represents
|
||||
// a zero value.
|
||||
func (f *Flag) defaultIsZeroValue() bool {
|
||||
switch f.Value.(type) {
|
||||
case boolFlag:
|
||||
return f.DefValue == "false"
|
||||
case *durationValue:
|
||||
// Beginning in Go 1.7, duration zero values are "0s"
|
||||
return f.DefValue == "0" || f.DefValue == "0s"
|
||||
case *intValue, *int8Value, *int32Value, *int64Value, *uintValue, *uint8Value, *uint16Value, *uint32Value, *uint64Value, *countValue, *float32Value, *float64Value:
|
||||
return f.DefValue == "0"
|
||||
case *stringValue:
|
||||
return f.DefValue == ""
|
||||
case *ipValue, *ipMaskValue, *ipNetValue:
|
||||
return f.DefValue == "<nil>"
|
||||
case *intSliceValue, *stringSliceValue, *stringArrayValue:
|
||||
return f.DefValue == "[]"
|
||||
default:
|
||||
switch f.Value.String() {
|
||||
case "false":
|
||||
return true
|
||||
case "<nil>":
|
||||
return true
|
||||
case "":
|
||||
return true
|
||||
case "0":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// UnquoteUsage extracts a back-quoted name from the usage
|
||||
@@ -455,22 +471,19 @@ func UnquoteUsage(flag *Flag) (name string, usage string) {
|
||||
break // Only one back quote; use type name.
|
||||
}
|
||||
}
|
||||
// No explicit name, so use type if we can find one.
|
||||
name = "value"
|
||||
switch flag.Value.(type) {
|
||||
case boolFlag:
|
||||
|
||||
name = flag.Value.Type()
|
||||
switch name {
|
||||
case "bool":
|
||||
name = ""
|
||||
case *durationValue:
|
||||
name = "duration"
|
||||
case *float64Value:
|
||||
case "float64":
|
||||
name = "float"
|
||||
case *intValue, *int64Value:
|
||||
case "int64":
|
||||
name = "int"
|
||||
case *stringValue:
|
||||
name = "string"
|
||||
case *uintValue, *uint64Value:
|
||||
case "uint64":
|
||||
name = "uint"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -519,7 +532,7 @@ func (f *FlagSet) FlagUsages() string {
|
||||
}
|
||||
|
||||
line += usage
|
||||
if !isZeroValue(flag.DefValue) {
|
||||
if !flag.defaultIsZeroValue() {
|
||||
if flag.Value.Type() == "string" {
|
||||
line += fmt.Sprintf(" (default %q)", flag.DefValue)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user