| 106 | } |
| 107 | |
| 108 | func commandTree(cmd *cobra.Command) (res command) { |
| 109 | res.Path = cmd.CommandPath() |
| 110 | res.Short = cmd.Short |
| 111 | if len(cmd.Commands()) == 0 { |
| 112 | return |
| 113 | } |
| 114 | res.SubCommands = make(map[string]command, len(cmd.Commands())) |
| 115 | for _, cmd := range cmd.Commands() { |
| 116 | if !cmd.IsAvailableCommand() || cmd.IsAdditionalHelpTopicCommand() { |
| 117 | continue |
| 118 | } |
| 119 | res.SubCommands[cmd.Name()] = commandTree(cmd) |
| 120 | } |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | // GenTree generates a JSON tree for the given root command |
| 125 | func GenJSONTree(root *cobra.Command) *cobra.Command { |