func getSubCommands(cmd *cobra.Command) []*cobra.Command { subCommands := []*cobra.Command{} for _, subCmd := range cmd.Commands() { subCommands = append(subCommands, subCmd) subCommands = append(subCommands, getSubCommands(subCmd)...) } return subCommands }