MCPcopy Create free account
hub / github.com/diillson/chatcli / completeAtTokenArgs

Method completeAtTokenArgs

cli/cli_completer.go:176–193  ·  view source on GitHub ↗

completeAtTokenArgs handles `@file ` and `@command ` argument completion. Returns matched=false when the previous token is unrelated.

(args []string, line, word string)

Source from the content-addressed store, hash-verified

174// completeAtTokenArgs handles `@file <path>` and `@command <cmd>` argument
175// completion. Returns matched=false when the previous token is unrelated.
176func (cli *ChatCLI) completeAtTokenArgs(args []string, line, word string) ([]prompt.Suggest, bool) {
177 if len(args) == 0 {
178 return nil, false
179 }
180 previous := previousToken(args, line)
181 if previous == "" || strings.HasPrefix(word, "-") {
182 return nil, false
183 }
184 switch previous {
185 case "@file":
186 return cli.filePathCompleter(word), true
187 case "@command":
188 out := cli.systemCommandCompleter(word)
189 out = append(out, cli.filePathCompleter(word)...)
190 return out, true
191 }
192 return nil, false
193}
194
195// previousToken returns the word immediately before the cursor — either the
196// last completed token (when the line ends in whitespace) or the

Calls 3

filePathCompleterMethod · 0.95
previousTokenFunction · 0.85