MCPcopy
hub / github.com/cayleygraph/cayley / splitLine

Function splitLine

internal/repl/repl.go:228–244  ·  view source on GitHub ↗

Splits a line into a command and its arguments e.g. ":a b c d ." will be split into ":a" and " b c d ."

(line string)

Source from the content-addressed store, hash-verified

226// Splits a line into a command and its arguments
227// e.g. ":a b c d ." will be split into ":a" and " b c d ."
228func splitLine(line string) (string, string) {
229 var command, arguments string
230
231 line = strings.TrimSpace(line)
232
233 // An empty line/a line consisting of whitespace contains neither command nor arguments
234 if len(line) > 0 {
235 command = strings.Fields(line)[0]
236
237 // A line containing only a command has no arguments
238 if len(line) > len(command) {
239 arguments = line[len(command):]
240 }
241 }
242
243 return command, arguments
244}
245
246func terminal(path string) (*liner.State, error) {
247 term := liner.NewLiner()

Callers 2

ReplFunction · 0.85
TestSplitLinesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSplitLinesFunction · 0.68