MCPcopy
hub / github.com/spf13/cobra / GenMarkdownTreeCustom

Function GenMarkdownTreeCustom

doc/md_docs.go:133–158  ·  view source on GitHub ↗

GenMarkdownTreeCustom is the same as GenMarkdownTree, but with custom filePrepender and linkHandler.

(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string)

Source from the content-addressed store, hash-verified

131// GenMarkdownTreeCustom is the same as GenMarkdownTree, but
132// with custom filePrepender and linkHandler.
133func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
134 for _, c := range cmd.Commands() {
135 if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {
136 continue
137 }
138 if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil {
139 return err
140 }
141 }
142
143 basename := strings.ReplaceAll(cmd.CommandPath(), " ", "_") + markdownExtension
144 filename := filepath.Join(dir, basename)
145 f, err := os.Create(filename)
146 if err != nil {
147 return err
148 }
149 defer f.Close()
150
151 if _, err := io.WriteString(f, filePrepender(filename)); err != nil {
152 return err
153 }
154 if err := GenMarkdownCustom(cmd, f, linkHandler); err != nil {
155 return err
156 }
157 return nil
158}

Callers 1

GenMarkdownTreeFunction · 0.85

Calls 5

GenMarkdownCustomFunction · 0.85
CommandsMethod · 0.80
IsAvailableCommandMethod · 0.80
CommandPathMethod · 0.80

Tested by

no test coverage detected