(env *execenv.Env, opts commandOptions)
| 34 | } |
| 35 | |
| 36 | func 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 | |
| 76 | type commandSorterByName []*cobra.Command |
| 77 |
no test coverage detected