| 327 | } |
| 328 | |
| 329 | func NewCmdHelpTopic(ios *iostreams.IOStreams, ht helpTopic) *cobra.Command { |
| 330 | cmd := &cobra.Command{ |
| 331 | Use: ht.name, |
| 332 | Short: ht.short, |
| 333 | Long: ht.long, |
| 334 | Example: ht.example, |
| 335 | Hidden: true, |
| 336 | Annotations: map[string]string{ |
| 337 | "markdown:generate": "true", |
| 338 | "markdown:basename": "gh_help_" + ht.name, |
| 339 | }, |
| 340 | } |
| 341 | |
| 342 | cmd.SetUsageFunc(func(c *cobra.Command) error { |
| 343 | return helpTopicUsageFunc(ios.ErrOut, c) |
| 344 | }) |
| 345 | |
| 346 | cmd.SetHelpFunc(func(c *cobra.Command, _ []string) { |
| 347 | helpTopicHelpFunc(ios.Out, c) |
| 348 | }) |
| 349 | |
| 350 | return cmd |
| 351 | } |
| 352 | |
| 353 | func helpTopicHelpFunc(w io.Writer, command *cobra.Command) { |
| 354 | fmt.Fprint(w, command.Long) |