(cmd *cobra.Command, header *GenManHeader)
| 208 | } |
| 209 | |
| 210 | func genMan(cmd *cobra.Command, header *GenManHeader) []byte { |
| 211 | cmd.InitDefaultHelpCmd() |
| 212 | cmd.InitDefaultHelpFlag() |
| 213 | |
| 214 | // something like `rootcmd-subcmd1-subcmd2` |
| 215 | dashCommandName := strings.Replace(cmd.CommandPath(), " ", "-", -1) |
| 216 | |
| 217 | buf := new(bytes.Buffer) |
| 218 | |
| 219 | manPreamble(buf, header, cmd, dashCommandName) |
| 220 | for _, g := range root.GroupedCommands(cmd) { |
| 221 | fmt.Fprintf(buf, "# %s\n", strings.ToUpper(g.Title)) |
| 222 | for _, subcmd := range g.Commands { |
| 223 | fmt.Fprintf(buf, "`%s`\n: %s\n\n", manLink(subcmd), subcmd.Short) |
| 224 | } |
| 225 | } |
| 226 | manPrintOptions(buf, cmd) |
| 227 | manPrintAliases(buf, cmd) |
| 228 | manPrintJSONFields(buf, cmd) |
| 229 | manPrintExitCodes(buf) |
| 230 | if len(cmd.Example) > 0 { |
| 231 | buf.WriteString("# EXAMPLE\n") |
| 232 | buf.WriteString(fmt.Sprintf("```\n%s\n```\n", cmd.Example)) |
| 233 | } |
| 234 | if cmd.HasParent() { |
| 235 | buf.WriteString("# SEE ALSO\n") |
| 236 | buf.WriteString(fmt.Sprintf("`%s`\n", manLink(cmd.Parent()))) |
| 237 | } |
| 238 | return buf.Bytes() |
| 239 | } |
| 240 | |
| 241 | func manLink(cmd *cobra.Command) string { |
| 242 | p := cmd.CommandPath() |
no test coverage detected