(tokens: string[])
| 220 | } |
| 221 | |
| 222 | function getGrepCommandTokenIndex(tokens: string[]): number | null { |
| 223 | if (tokens.length === 0) { |
| 224 | return null; |
| 225 | } |
| 226 | |
| 227 | if (isGrepToken(tokens[0])) { |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | if (tokens[0] === "command" && tokens[1] && isGrepToken(tokens[1])) { |
| 232 | return 1; |
| 233 | } |
| 234 | |
| 235 | // Handle common patterns like: sudo grep file, sudo -n grep file, sudo -u user grep file |
| 236 | if (tokens[0] === "sudo") { |
| 237 | for (let i = 1; i < tokens.length && i < 8; i++) { |
| 238 | if (isGrepToken(tokens[i])) { |
| 239 | return i; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | return null; |
| 245 | } |
| 246 | |
| 247 | function parseSearchCommandArgs( |
| 248 | command: SearchCommand, |
no test coverage detected