X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcliparser.cpp;h=c4ca9b8c847d059dca0f17e59fe6b361c3919ea6;hb=6fe50f14efa32c2ed95e7b34a4ba1fd1604617ec;hp=e3b8addde38d83cec27a44021a21719a761f19d2;hpb=6564dcd249b38c3eeee9cc53b161ba338cfa7379;p=quassel.git diff --git a/src/common/cliparser.cpp b/src/common/cliparser.cpp index e3b8addd..c4ca9b8c 100644 --- a/src/common/cliparser.cpp +++ b/src/common/cliparser.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "cliparser.h" +#include #include #include #include @@ -38,7 +39,7 @@ void CliParser::addArgument(const QString &longName, const CliParserArg &arg) { bool CliParser::addLongArg(const CliParserArg::CliArgType type, const QString &name, const QString &value) { if(argsHash.contains(name)){ if(type == CliParserArg::CliArgOption && argsHash.value(name).type == type) { - argsHash[name].value = value; + argsHash[name].value = escapedValue(value); return true; } else if (type == CliParserArg::CliArgSwitch && argsHash.value(name).type == type) { @@ -54,7 +55,7 @@ bool CliParser::addShortArg(const CliParserArg::CliArgType type, const char shor QString longName = lnameOfShortArg(shortName); if(!longName.isNull()) { if(type == CliParserArg::CliArgOption && argsHash.value(longName).type == type) { - argsHash[longName].value = value; + argsHash[longName].value = escapedValue(value); return true; } else if (type == CliParserArg::CliArgSwitch) { @@ -73,6 +74,14 @@ bool CliParser::addShortArg(const CliParserArg::CliArgType type, const char shor return false; } +QString CliParser::escapedValue(const QString &value) { + QString escapedValue = value; + if(escapedValue.startsWith("~")) + escapedValue.replace(0, 1, QDir::homePath()); + + return escapedValue; +} + bool CliParser::parse() { QStringList::const_iterator currentArg; for (currentArg = argsRaw.constBegin(); currentArg != argsRaw.constEnd(); ++currentArg) {