MCPcopy Create free account
hub / github.com/cli/cli / rootHelpFunc

Function rootHelpFunc

pkg/cmd/root/help.go:92–115  ·  view source on GitHub ↗
(f *cmdutil.Factory, command *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

90}
91
92func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {
93 flags := command.Flags()
94
95 if isRootCmd(command) {
96 if versionVal, err := flags.GetBool("version"); err == nil && versionVal {
97 fmt.Fprint(f.IOStreams.Out, command.Annotations["versionInfo"])
98 return
99 } else if err != nil {
100 fmt.Fprintln(f.IOStreams.ErrOut, err)
101 hasFailed = true
102 return
103 }
104 }
105
106 cs := f.IOStreams.ColorScheme()
107
108 if help, _ := flags.GetBool("help"); !help && !command.Runnable() && len(flags.Args()) > 0 {
109 nestedSuggestFunc(f.IOStreams.ErrOut, command, flags.Args()[0])
110 hasFailed = true
111 return
112 }
113
114 WriteHelp(f.IOStreams.Out, cs, command)
115}
116
117// WriteHelp renders the full help text for command to w. This is the same
118// output produced by `gh <command> --help`, exposed separately so that callers

Callers 1

NewCmdRootFunction · 0.85

Calls 4

isRootCmdFunction · 0.85
nestedSuggestFuncFunction · 0.85
WriteHelpFunction · 0.85
ColorSchemeMethod · 0.80

Tested by

no test coverage detected