(w io.Writer, dir, sectionTitle string, cmds []*kingpin.CmdModel, advanced bool)
| 245 | } |
| 246 | |
| 247 | func generateSubcommands(w io.Writer, dir, sectionTitle string, cmds []*kingpin.CmdModel, advanced bool) { |
| 248 | cmds = append([]*kingpin.CmdModel(nil), cmds...) |
| 249 | |
| 250 | first := true |
| 251 | |
| 252 | for _, c := range cmds { |
| 253 | if c.Hidden != advanced { |
| 254 | continue |
| 255 | } |
| 256 | |
| 257 | if first { |
| 258 | fmt.Fprintf(w, "\n### %v\n\n", strings.TrimSuffix(sectionTitle, ".")) //nolint:errcheck |
| 259 | |
| 260 | first = false |
| 261 | } |
| 262 | |
| 263 | subcommandSlug := strings.ReplaceAll(c.FullCommand, " ", "-") |
| 264 | helpSummary := strings.SplitN(c.Help, "\n", 2)[0] //nolint:mnd |
| 265 | helpSummary = strings.TrimSuffix(helpSummary, ".") |
| 266 | fmt.Fprintf(w, "* [`%v`](%v) - %v\n", c.FullCommand, subcommandSlug+"/", helpSummary) //nolint:errcheck |
| 267 | generateSubcommandPage(filepath.Join(dir, subcommandSlug+".md"), c) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func generateSubcommandPage(fname string, cmd *kingpin.CmdModel) { |
| 272 | f, err := os.Create(fname) //nolint:gosec |
no test coverage detected