File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 66 "fmt"
77 "io"
88 "os"
9- "reflect"
109 "regexp"
1110 "runtime"
1211 "sort"
@@ -567,13 +566,11 @@ func (tabularTemplate) Prettify(s string) string {
567566// getFlagDefaultValue returns the default text or default value of a flag.
568567// cli.BoolFlag will always return an default.
569568func getFlagDefaultValue (f cli.DocGenerationFlag ) (value , text string ) {
570- // GetDefaultText also returns GetValue so we have to use reflection
571- if ref := reflect .ValueOf (f ); ref .Kind () == reflect .Ptr && ref .Elem ().Kind () == reflect .Struct {
572- if val := ref .Elem ().FieldByName ("DefaultText" ); val .IsValid () && val .Type ().Kind () == reflect .String {
573- if defaultText := val .Interface ().(string ); defaultText != "" {
574- return "" , defaultText
575- }
569+ if defaultText := f .GetDefaultText (); defaultText != "" {
570+ if strings .HasPrefix (defaultText , "\" " ) && strings .HasSuffix (defaultText , "\" " ) {
571+ defaultText = defaultText [1 : len (defaultText )- 1 ]
576572 }
573+ return "" , defaultText
577574 }
578575
579576 if ! f .TakesValue () {
@@ -583,5 +580,11 @@ func getFlagDefaultValue(f cli.DocGenerationFlag) (value, text string) {
583580 return "" , ""
584581 }
585582
586- return f .GetValue (), ""
583+ if value := f .GetValue (); value != "" {
584+ if strings .HasPrefix (value , "\" " ) && strings .HasSuffix (value , "\" " ) {
585+ value = value [1 : len (value )- 1 ]
586+ }
587+ return value , ""
588+ }
589+ return "" , ""
587590}
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ go 1.24.4
44
55require (
66 github.com/cpuguy83/go-md2man/v2 v2.0.2
7- github.com/stretchr/testify v1.10.0
8- github.com/urfave/cli/v3 v3.4.1
7+ github.com/stretchr/testify v1.11.1
8+ github.com/urfave/cli/v3 v3.5.0
99)
1010
1111require (
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
88github.com/russross/blackfriday/v2 v2.1.0 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
99github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA =
1010github.com/stretchr/testify v1.10.0 /go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY =
11+ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U =
12+ github.com/stretchr/testify v1.11.1 /go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U =
1113github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM =
1214github.com/urfave/cli/v3 v3.4.1 /go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo =
15+ github.com/urfave/cli/v3 v3.5.0 h1:qCuFMmdayTF3zmjG8TSsoBzrDqszNrklYg2x3g4MSgw =
16+ github.com/urfave/cli/v3 v3.5.0 /go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso =
1317gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM =
1418gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 /go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0 =
1519gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA =
You can’t perform that action at this time.
0 commit comments