@@ -27,6 +27,8 @@ import (
27
27
"github.com/spf13/cobra"
28
28
)
29
29
30
+ const markdownExtension = ".md"
31
+
30
32
func printOptions (buf * bytes.Buffer , cmd * cobra.Command , name string ) error {
31
33
flags := cmd .NonInheritedFlags ()
32
34
flags .SetOutput (buf )
@@ -83,7 +85,7 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string)
83
85
if cmd .HasParent () {
84
86
parent := cmd .Parent ()
85
87
pname := parent .CommandPath ()
86
- link := pname + ".md"
88
+ link := pname + markdownExtension
87
89
link = strings .ReplaceAll (link , " " , "_" )
88
90
buf .WriteString (fmt .Sprintf ("* [%s](%s)\t - %s\n " , pname , linkHandler (link ), parent .Short ))
89
91
cmd .VisitParents (func (c * cobra.Command ) {
@@ -101,7 +103,7 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string)
101
103
continue
102
104
}
103
105
cname := name + " " + child .Name ()
104
- link := cname + ".md"
106
+ link := cname + markdownExtension
105
107
link = strings .ReplaceAll (link , " " , "_" )
106
108
buf .WriteString (fmt .Sprintf ("* [%s](%s)\t - %s\n " , cname , linkHandler (link ), child .Short ))
107
109
}
@@ -138,7 +140,7 @@ func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHa
138
140
}
139
141
}
140
142
141
- basename := strings .ReplaceAll (cmd .CommandPath (), " " , "_" ) + ".md"
143
+ basename := strings .ReplaceAll (cmd .CommandPath (), " " , "_" ) + markdownExtension
142
144
filename := filepath .Join (dir , basename )
143
145
f , err := os .Create (filename )
144
146
if err != nil {
0 commit comments