File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -578,21 +578,19 @@ func getFlagDefaultValue(f cli.DocGenerationFlag) (value, text string) {
578578 return "" , ""
579579 }
580580
581- var defaultText string
582- if v , ok := f .(interface { GetDefaultText () string }); ok {
583- defaultText = v .GetDefaultText ()
581+ if _ , ok := f .(interface { GetDefaultText () string }); ok {
582+ // GetDefaultText also returns GetValue so we have to use reflection
583+ if ref := reflect .ValueOf (f ); ref .Kind () == reflect .Ptr && ref .Elem ().Kind () == reflect .Struct {
584+ if val := ref .Elem ().FieldByName ("DefaultText" ); val .IsValid () && val .Type ().Kind () == reflect .String {
585+ if defaultText := val .Interface ().(string ); defaultText != "" {
586+ return "" , defaultText
587+ }
588+ }
589+ }
584590 }
585591
586592 if v , ok := f .(interface { GetValue () string }); ok {
587- value = v .GetValue ()
588-
589- // GetDefaultText also returns GetValue if default text not set
590- // but quotes it
591- if strings .Trim (defaultText , "\" " ) == value {
592- return value , ""
593- } else if defaultText != "" {
594- return "" , defaultText
595- }
593+ return v .GetValue (), ""
596594 }
597595
598596 var ref = reflect .ValueOf (f )
You can’t perform that action at this time.
0 commit comments