MCPcopy Index your code
hub / github.com/docker/cli / topCommands

Function topCommands

cli/cobra.go:261–280  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

259}
260
261func 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
282func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
283 cmds := []*cobra.Command{}

Callers 1

hasTopCommandsFunction · 0.85

Calls 2

isPluginFunction · 0.85
ParentMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…