I was able to hack something up. This is just a simple recursive function that filters out some noise by command name (e.g I skip over autogenerated help and bash completion commands)
var dumpAllHelp = "dump-all-help"
var recHelpCmd = &cobra.Command{
Use: dumpAllHelp,
Short: "dump all help texts",
Long: "dump all help texts",
Run: func(_ *cobra.Command, _ []string) {
dumpHelp(rootCmd, true)
},
}
func dumpHelp(c *cobra.Command, root bool) {
if !root {
fmt.Println("")
fmt.Println("========================================================")
fmt.Println("")
}
c.Help()
for _, child := range c.Commands() {
if child.Hidden || child.Name() == "completion" || child.Name() == "help" || child.Name() == dumpAllHelp {
continue
}
dumpHelp(child, false)
}
}
func init() {
rootCmd.AddCommand(recHelpCmd)
}