MCPcopy Create free account
hub / github.com/algolia/cli / Execute

Function Execute

test/helpers.go:114–135  ·  view source on GitHub ↗
(cmd *cobra.Command, cli string, inOut *CmdInOut)

Source from the content-addressed store, hash-verified

112}
113
114func Execute(cmd *cobra.Command, cli string, inOut *CmdInOut) (*CmdInOut, error) {
115 argv, err := shlex.Split(cli)
116 if err != nil {
117 return nil, err
118 }
119 cmd.SetArgs(argv)
120
121 if inOut.InBuf != nil {
122 cmd.SetIn(inOut.InBuf)
123 } else {
124 cmd.SetIn(&bytes.Buffer{})
125 }
126 cmd.SetOut(io.Discard)
127 cmd.SetErr(io.Discard)
128
129 _, err = cmd.ExecuteC()
130 if err != nil {
131 return nil, err
132 }
133
134 return inOut, nil
135}

Calls

no outgoing calls