MCPcopy Index your code
hub / github.com/cli/cli / printOptions

Function printOptions

internal/docs/markdown.go:38–59  ·  view source on GitHub ↗
(w io.Writer, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

36}
37
38func printOptions(w io.Writer, cmd *cobra.Command) error {
39 flags := cmd.NonInheritedFlags()
40 flags.SetOutput(w)
41 if flags.HasAvailableFlags() {
42 fmt.Fprint(w, "### Options\n\n")
43 if err := printFlagsHTML(w, flags); err != nil {
44 return err
45 }
46 fmt.Fprint(w, "\n\n")
47 }
48
49 parentFlags := cmd.InheritedFlags()
50 parentFlags.SetOutput(w)
51 if hasNonHelpFlags(parentFlags) {
52 fmt.Fprint(w, "### Options inherited from parent commands\n\n")
53 if err := printFlagsHTML(w, parentFlags); err != nil {
54 return err
55 }
56 fmt.Fprint(w, "\n\n")
57 }
58 return nil
59}
60
61func hasNonHelpFlags(fs *pflag.FlagSet) (found bool) {
62 fs.VisitAll(func(f *pflag.Flag) {

Callers 1

genMarkdownCustomFunction · 0.85

Calls 2

printFlagsHTMLFunction · 0.85
hasNonHelpFlagsFunction · 0.85

Tested by

no test coverage detected