(cmd *cobra.Command)
| 259 | } |
| 260 | |
| 261 | func topCommands(cmd *cobra.Command) []*cobra.Command { |
| 262 | cmds := []*cobra.Command{} |
| 263 | if cmd.Parent() != nil { |
| 264 | // for now, only use top-commands for the root-command, and skip |
| 265 | // for sub-commands |
| 266 | return cmds |
| 267 | } |
| 268 | for _, sub := range cmd.Commands() { |
| 269 | if isPlugin(sub) || !sub.IsAvailableCommand() { |
| 270 | continue |
| 271 | } |
| 272 | if _, ok := sub.Annotations["category-top"]; ok { |
| 273 | cmds = append(cmds, sub) |
| 274 | } |
| 275 | } |
| 276 | sort.SliceStable(cmds, func(i, j int) bool { |
| 277 | return sortorder.NaturalLess(cmds[i].Annotations["category-top"], cmds[j].Annotations["category-top"]) |
| 278 | }) |
| 279 | return cmds |
| 280 | } |
| 281 | |
| 282 | func operationSubCommands(cmd *cobra.Command) []*cobra.Command { |
| 283 | cmds := []*cobra.Command{} |
no test coverage detected
searching dependent graphs…