(line string, lineNo int)
| 66 | } |
| 67 | |
| 68 | func 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 |
no test coverage detected