Show BoolFlag default value in help usage

now that BoolTFlag is gone
This commit is contained in:
Dan Buch 2016-05-21 20:02:08 -04:00
parent 65357985c2
commit fac67ac91a
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
2 changed files with 4 additions and 4 deletions

View File

@ -624,8 +624,8 @@ func stringifyFlag(f Flag) string {
defaultValueString := "" defaultValueString := ""
val := fv.FieldByName("Value") val := fv.FieldByName("Value")
if val.IsValid() && val.Kind() != reflect.Bool { if val.IsValid() {
needsPlaceholder = true needsPlaceholder = val.Kind() != reflect.Bool
defaultValueString = fmt.Sprintf(" (default: %v)", val.Interface()) defaultValueString = fmt.Sprintf(" (default: %v)", val.Interface())
if val.Kind() == reflect.String && val.String() != "" { if val.Kind() == reflect.String && val.String() != "" {

View File

@ -14,8 +14,8 @@ var boolFlagTests = []struct {
name string name string
expected string expected string
}{ }{
{"help", "--help\t"}, {"help", "--help\t(default: false)"},
{"h", "-h\t"}, {"h", "-h\t(default: false)"},
} }
func TestBoolFlagHelpOutput(t *testing.T) { func TestBoolFlagHelpOutput(t *testing.T) {