-void CliParser::addArgument(const CliParserArg::CliArgType type, const QString longName, const char shortName, const QString help, const QString def) {
- CliParserArg arg;
- if(type == CliParserArg::CliArgOption)
- arg = CliParserArg(CliParserArg::CliArgOption, shortName, help, def);
- else
- arg = CliParserArg(CliParserArg::CliArgSwitch, shortName, help);
- argsHash.insert(longName, arg);
+void CliParser::addArgument(const QString &longName_, const CliParserArg &arg) {
+ QString longName = longName_;
+ longName.remove(QRegExp("\\s*<.*>\\s*")); // KCmdLineArgs takes args of the form "arg <defval>"
+ if(argsMap.contains(longName)) qWarning() << "Warning: Multiple definition of argument" << longName;
+ if(arg.shortName != 0 && !lnameOfShortArg(arg.shortName).isNull())
+ qWarning().nospace() << "Warning: Redefining shortName '" << arg.shortName << "' for " << longName << " previously defined for " << lnameOfShortArg(arg.shortName);
+ argsMap.insert(longName, arg);