Show BoolFlag default value in help usage
now that BoolTFlag is gone
This commit is contained in:
parent
65357985c2
commit
fac67ac91a
4
flag.go
4
flag.go
@ -624,8 +624,8 @@ func stringifyFlag(f Flag) string {
|
||||
defaultValueString := ""
|
||||
val := fv.FieldByName("Value")
|
||||
|
||||
if val.IsValid() && val.Kind() != reflect.Bool {
|
||||
needsPlaceholder = true
|
||||
if val.IsValid() {
|
||||
needsPlaceholder = val.Kind() != reflect.Bool
|
||||
defaultValueString = fmt.Sprintf(" (default: %v)", val.Interface())
|
||||
|
||||
if val.Kind() == reflect.String && val.String() != "" {
|
||||
|
@ -14,8 +14,8 @@ var boolFlagTests = []struct {
|
||||
name string
|
||||
expected string
|
||||
}{
|
||||
{"help", "--help\t"},
|
||||
{"h", "-h\t"},
|
||||
{"help", "--help\t(default: false)"},
|
||||
{"h", "-h\t(default: false)"},
|
||||
}
|
||||
|
||||
func TestBoolFlagHelpOutput(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user