MCPcopy Index your code
hub / github.com/larksuite/cli / parseLine

Function parseLine

cmd/cmdexample_parse_test.go:68–87  ·  view source on GitHub ↗
(line string, lineNo int)

Source from the content-addressed store, hash-verified

66}
67
68func parseLine(line string, lineNo int) []ref {
69 var refs []ref
70 rest := line
71 for {
72 idx := strings.Index(rest, cliToken)
73 if idx < 0 {
74 break
75 }
76 after := rest[idx+len(cliToken):]
77 beforeOK := idx == 0 || isBoundary(rest[idx-1])
78 afterOK := after == "" || isBoundary(after[0])
79 if beforeOK && afterOK {
80 if words, flags, raw, ok := parseCmd(after); ok {
81 refs = append(refs, ref{line: lineNo, raw: cliToken + raw, words: words, flags: flags})
82 }
83 }
84 rest = after
85 }
86 return refs
87}
88
89// parseCmd tokenizes the text following "lark-cli" into leading command words
90// (the subcommand path, up to the first flag) and flag tokens. It stops at a

Callers 1

parseRefsFunction · 0.85

Calls 2

isBoundaryFunction · 0.85
parseCmdFunction · 0.85

Tested by

no test coverage detected