MCPcopy Create free account
hub / github.com/dim-an/cod / apiCompleteWordsMain

Function apiCompleteWordsMain

commands.go:255–280  ·  view source on GitHub ↗
(_ uint, cword int, words []string)

Source from the content-addressed store, hash-verified

253}
254
255func apiCompleteWordsMain(_ uint, cword int, words []string) {
256 app := NewApplication()
257 defer app.Close()
258
259 if len(words) == 0 {
260 fatal(fmt.Errorf("command line cannot be empty"))
261 }
262
263 env := os.Environ()
264 dir, err := os.Getwd()
265 verifyFatal(err)
266 executablePath, err := datastore.CanonizeExecutablePath(words[0], dir, util.GetPathVar(env), util.GetHomeVar(env))
267 verifyFatal(err)
268
269 req := server.CompleteWordsRequest{
270 Words: append([]string{executablePath}, words[1:]...),
271 CWord: cword,
272 }
273 rsp := server.CompleteWordsResponse{}
274 err = app.Client().Request(&req, &rsp)
275 verifyFatal(err)
276
277 for _, c := range rsp.Completions {
278 fmt.Println(c)
279 }
280}
281
282func learnMain(helpCommand []string) {
283 config, err := server.DefaultConfiguration()

Callers 1

mainFunction · 0.85

Calls 9

CloseMethod · 0.95
ClientMethod · 0.95
CanonizeExecutablePathFunction · 0.92
GetPathVarFunction · 0.92
GetHomeVarFunction · 0.92
NewApplicationFunction · 0.85
verifyFatalFunction · 0.85
RequestMethod · 0.80
fatalFunction · 0.70

Tested by

no test coverage detected