(_ uint, cword int, words []string)
| 253 | } |
| 254 | |
| 255 | func 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 | |
| 282 | func learnMain(helpCommand []string) { |
| 283 | config, err := server.DefaultConfiguration() |
no test coverage detected