MCPcopy Create free account
hub / github.com/dropbox/dbxcli / publicCommandSubtree

Function publicCommandSubtree

cmd/help_json.go:350–373  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

348}
349
350func publicCommandSubtree(cmd *cobra.Command) []*cobra.Command {
351 if cmd == nil {
352 return nil
353 }
354 var commands []*cobra.Command
355 var walk func(*cobra.Command)
356 walk = func(current *cobra.Command) {
357 if !current.Hidden {
358 commands = append(commands, current)
359 }
360 children := append([]*cobra.Command{}, current.Commands()...)
361 sort.Slice(children, func(i, j int) bool {
362 return jsonCommandPath(children[i]) < jsonCommandPath(children[j])
363 })
364 for _, child := range children {
365 if child.Hidden {
366 continue
367 }
368 walk(child)
369 }
370 }
371 walk(cmd)
372 return commands
373}
374
375func jsonCommandManifestFor(cmd *cobra.Command) jsonCommandManifest {
376 cmd.InitDefaultHelpFlag()

Calls 1

jsonCommandPathFunction · 0.85