Merge pull request #438 from urfave/show-bool-default

Show BoolFlag default value in help usage
This commit is contained in:
Jesse Szwedko 2016-05-28 12:03:46 -07:00
commit dddab48818
2 changed files with 4 additions and 4 deletions

View File

@ -670,8 +670,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() != "" {

View File

@ -15,8 +15,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) {