DefaultShowRootCommandHelp is the default implementation of ShowRootCommandHelp.
(cmd *Command)
| 154 | |
| 155 | // DefaultShowRootCommandHelp is the default implementation of ShowRootCommandHelp. |
| 156 | func DefaultShowRootCommandHelp(cmd *Command) error { |
| 157 | tmpl := cmd.CustomRootCommandHelpTemplate |
| 158 | if tmpl == "" { |
| 159 | tracef("using RootCommandHelpTemplate") |
| 160 | tmpl = RootCommandHelpTemplate |
| 161 | } |
| 162 | |
| 163 | if cmd.ExtraInfo == nil { |
| 164 | HelpPrinter(cmd.Root().Writer, tmpl, cmd.Root()) |
| 165 | return nil |
| 166 | } |
| 167 | |
| 168 | tracef("setting ExtraInfo in customAppData") |
| 169 | customAppData := func() map[string]any { |
| 170 | return map[string]any{ |
| 171 | "ExtraInfo": cmd.ExtraInfo, |
| 172 | } |
| 173 | } |
| 174 | HelpPrinterCustom(cmd.Root().Writer, tmpl, cmd.Root(), customAppData()) |
| 175 | |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // DefaultRootCommandComplete prints the list of subcommands as the default completion method. |
| 180 | func DefaultRootCommandComplete(ctx context.Context, cmd *Command) { |