detectCodeIndexingFromCommand function
Detects if a bash command is using a code indexing CLI tool.
Returns the code indexing tool identifier, or null if not a code indexing command.
Implementation
CodeIndexingTool? detectCodeIndexingFromCommand(String command) {
final trimmed = command.trim();
final firstWord = trimmed.split(RegExp(r'\s+')).firstOrNull?.toLowerCase();
if (firstWord == null) return null;
// Check for npx/bunx prefixed commands
if (firstWord == 'npx' || firstWord == 'bunx') {
final words = trimmed.split(RegExp(r'\s+'));
final secondWord = words.length > 1 ? words[1].toLowerCase() : null;
if (secondWord != null && _cliCommandMapping.containsKey(secondWord)) {
return _cliCommandMapping[secondWord];
}
}
return _cliCommandMapping[firstWord];
}