MCPcopy Create free account
hub / github.com/git-bug/git-bug / runCommands

Function runCommands

commands/commands.go:36–74  ·  view source on GitHub ↗
(env *execenv.Env, opts commandOptions)

Source from the content-addressed store, hash-verified

34}
35
36func runCommands(env *execenv.Env, opts commandOptions) error {
37 first := true
38
39 var allCmds []*cobra.Command
40 queue := []*cobra.Command{NewRootCommand()}
41
42 for len(queue) > 0 {
43 cmd := queue[0]
44 queue = queue[1:]
45 allCmds = append(allCmds, cmd)
46 queue = append(queue, cmd.Commands()...)
47 }
48
49 sort.Sort(commandSorterByName(allCmds))
50
51 for _, cmd := range allCmds {
52 if !first {
53 env.Out.Println()
54 }
55
56 first = false
57
58 if opts.desc {
59 env.Out.Printf("# %s\n", cmd.Short)
60 }
61
62 env.Out.Print(cmd.UseLine())
63
64 if opts.desc {
65 env.Out.Println()
66 }
67 }
68
69 if !opts.desc {
70 env.Out.Println()
71 }
72
73 return nil
74}
75
76type commandSorterByName []*cobra.Command
77

Callers 1

newCommandsCommandFunction · 0.85

Calls 5

NewRootCommandFunction · 0.85
commandSorterByNameTypeAlias · 0.85
PrintlnMethod · 0.65
PrintfMethod · 0.65
PrintMethod · 0.65

Tested by

no test coverage detected