mergeArguments method
To process the arguments correctly, the system checks for quotation
marks in the arguments, as well as for opening and closing brackets,
to ensure that the mergedArguments contain related
data to actual parse it later.
Implementation
List<String> mergeArguments(List<String> rawArguments) {
final List<String> args = [];
String arg = "";
bool openQuotes = false;
for (final String raw in rawArguments) {
arg += arg.isEmpty ? raw : " $raw";
for (int i = 0; i < raw.length; i++) {
if (i > 0 && raw[i - 1] == "\\") {
continue;
}
if (raw[i] == "\"") {
openQuotes = !openQuotes;
}
}
if (!openQuotes) {
args.add(arg);
arg = "";
}
}
return args;
}