MCPcopy
hub / github.com/cli/cli / cmdRef

Function cmdRef

pkg/cmd/root/help_reference.go:54–78  ·  view source on GitHub ↗
(w io.Writer, cmd *cobra.Command, depth int)

Source from the content-addressed store, hash-verified

52}
53
54func cmdRef(w io.Writer, cmd *cobra.Command, depth int) {
55 // Name + Description
56 fmt.Fprintf(w, "%s `%s`\n\n", strings.Repeat("#", depth), cmd.UseLine())
57 fmt.Fprintf(w, "%s\n\n", cmd.Short)
58
59 // Flags
60 // TODO: fold in InheritedFlags/PersistentFlags, but omit `--help` due to repetitiveness
61 if flagUsages := cmd.Flags().FlagUsages(); flagUsages != "" {
62 fmt.Fprintf(w, "```\n%s````\n\n", dedent(flagUsages))
63 }
64
65 // Aliases
66 if len(cmd.Aliases) > 0 {
67 fmt.Fprintf(w, "%s\n\n", "Aliases")
68 fmt.Fprintf(w, "\n%s\n\n", dedent(strings.Join(BuildAliasList(cmd, cmd.Aliases), ", ")))
69 }
70
71 // Subcommands
72 for _, c := range cmd.Commands() {
73 if c.Hidden {
74 continue
75 }
76 cmdRef(w, c, depth+1)
77 }
78}

Callers 1

stringifyReferenceFunction · 0.85

Calls 3

dedentFunction · 0.85
BuildAliasListFunction · 0.85
JoinMethod · 0.80

Tested by

no test coverage detected