(f *cmdutil.Factory, command *cobra.Command, _ []string)
| 90 | } |
| 91 | |
| 92 | func 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 |
no test coverage detected