getConfigPath function
Implementation
String? getConfigPath(List<String> tokens) {
final flagRe = RegExp(r'^(-[A-Zabd-z]*c=?|--config(?:=|$))');
for (var i = 0; i < tokens.length; i++) {
final token = tokens[i];
final match = flagRe.firstMatch(token);
if (match == null) continue;
// Group 1 is the flag, up to and including the =.
final flag = match.group(1)!;
final withoutOption = token.substring(flag.length);
if (withoutOption.isEmpty) {
if (i + 1 < tokens.length) return tokens[i + 1];
} else {
return withoutOption;
}
}
return null;
}