MCPcopy
hub / github.com/redspread/spread / commands

Function commands

cmd/spread/spread.go:27–45  ·  view source on GitHub ↗

Get commands provided by spread

(spread *cli.SpreadCli)

Source from the content-addressed store, hash-verified

25
26// Get commands provided by spread
27func commands(spread *cli.SpreadCli) []clilib.Command {
28 cmds := []clilib.Command{}
29
30 cliType := reflect.ValueOf(spread)
31 for i := 0; i < cliType.NumMethod(); i++ {
32 cmd := cliType.Method(i)
33
34 // check that is returning command
35 cmdType := cmd.Type()
36 if cmdType.NumOut() == 1 && cmdType.Out(0) == reflect.TypeOf(new(clilib.Command)) {
37 cmdFn := cmd.Interface().(func() *clilib.Command)
38 command := cmdFn()
39 if command != nil {
40 cmds = append(cmds, *command)
41 }
42 }
43 }
44 return cmds
45}
46
47func app() *clilib.App {
48 app := clilib.NewApp()

Callers 1

mainFunction · 0.85

Calls 1

TypeMethod · 0.65

Tested by

no test coverage detected