I'm trying to parse multiple times the same parameter with QCommandLineParser. The thing is that when I try to parse them, it returns me an empty QStringList, which means that parser encountered some kind of error, even though those are correctly set up.
I run my program this way : ./dns-benchmark domains.txt -d "208.67.222.222" -d "208.67.220.220"
I've got a positional argument that is correctly returned, but then my -d
arent :/
QCoreApplication coreApplication(argc, argv);
QCoreApplication::setApplicationName("dns-benchmark");
QCoreApplication::setApplicationVersion("0.0.1");
QCommandLineParser parser;
parser.setApplicationDescription("Benchmarks a bunch of different DNS servers.");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("source", QCoreApplication::translate("main", "Source file containing the domains to resolve."));
QCommandLineOption supplementaryDnsOption(QStringList() << "d" << "dns", "Supplementary DNS to benchmark.", "IPv4 or IPv6 address");
parser.addOption(supplementaryDnsOption);
parser.process(coreApplication);
const QStringList args = parser.positionalArguments();
QString domainsToResolveFilePath = args.at(0);
QLinkedList<QHostAddress> dnsList;
if (parser.isSet(supplementaryDnsOption)) {
const QStringList supplementaryDns = parser.values(supplementaryDnsOption);
for (qint8 i = 0; i < supplementaryDns.size() -1; i++) {
dnsList.append(QHostAddress(supplementaryDns.at(i)));
}
}
but then my const QStringList supplementaryDns
is totally empty :/