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

Function printOptions

doc/md_docs.go:32–49  ·  view source on GitHub ↗
(buf *bytes.Buffer, cmd *cobra.Command, name string)

Source from the content-addressed store, hash-verified

30const markdownExtension = ".md"
31
32func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
33 flags := cmd.NonInheritedFlags()
34 flags.SetOutput(buf)
35 if flags.HasAvailableFlags() {
36 buf.WriteString("### Options\n\n```\n")
37 flags.PrintDefaults()
38 buf.WriteString("```\n\n")
39 }
40
41 parentFlags := cmd.InheritedFlags()
42 parentFlags.SetOutput(buf)
43 if parentFlags.HasAvailableFlags() {
44 buf.WriteString("### Options inherited from parent commands\n\n```\n")
45 parentFlags.PrintDefaults()
46 buf.WriteString("```\n\n")
47 }
48 return nil
49}
50
51// GenMarkdown creates markdown output.
52func GenMarkdown(cmd *cobra.Command, w io.Writer) error {

Callers 1

GenMarkdownCustomFunction · 0.85

Calls 4

NonInheritedFlagsMethod · 0.80
SetOutputMethod · 0.80
HasAvailableFlagsMethod · 0.80
InheritedFlagsMethod · 0.80

Tested by

no test coverage detected