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

Function previousToken

cli/cli_completer.go:198–206  ·  view source on GitHub ↗

previousToken returns the word immediately before the cursor — either the last completed token (when the line ends in whitespace) or the second-to-last token otherwise.

(args []string, line string)

Source from the content-addressed store, hash-verified

196// last completed token (when the line ends in whitespace) or the
197// second-to-last token otherwise.
198func previousToken(args []string, line string) string {
199 if strings.HasSuffix(line, " ") {
200 return args[len(args)-1]
201 }
202 if len(args) > 1 {
203 return args[len(args)-2]
204 }
205 return ""
206}
207
208// completeBareSlash powers the "/" → list of slash commands flow, merging
209// user-invocable skills so they surface alongside built-ins.

Callers 5

completeAtTokenArgsMethod · 0.85
completeCommandFlagsMethod · 0.85
TestPreviousTokenFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestPreviousTokenFunction · 0.68