Browse Source

Detect uknown command line parameters.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
ca2dc325f5
  1. 16
      src/main.cpp

16
src/main.cpp

@ -114,6 +114,7 @@ struct QBtCommandLineParameters @@ -114,6 +114,7 @@ struct QBtCommandLineParameters
#endif
int webUiPort;
QStringList torrents;
QString uknownParameter;
QBtCommandLineParameters()
: showHelp(false)
@ -154,6 +155,12 @@ int main(int argc, char *argv[]) @@ -154,6 +155,12 @@ int main(int argc, char *argv[])
const QBtCommandLineParameters params = parseCommandLine();
if (!params.uknownParameter.isEmpty()) {
displayBadArgMessage(QObject::tr("%1 is an uknown command line parameter.", "--random-parameter is an uknown command line parameter.")
.arg(params.uknownParameter));
return EXIT_FAILURE;
}
#ifndef Q_OS_WIN
if (params.showVersion) {
if (isOneArg) {
@ -292,6 +299,9 @@ QBtCommandLineParameters parseCommandLine() @@ -292,6 +299,9 @@ QBtCommandLineParameters parseCommandLine()
for (int i = 1; i < appArguments.size(); ++i) {
const QString& arg = appArguments[i];
if ((arg.startsWith("--") && !arg.endsWith(".torrent")) ||
(arg.startsWith("-") && arg.size() == 2)) {
//Parse known parameters
if ((arg == QLatin1String("-h")) || (arg == QLatin1String("--help"))) {
result.showHelp = true;
}
@ -314,6 +324,12 @@ QBtCommandLineParameters parseCommandLine() @@ -314,6 +324,12 @@ QBtCommandLineParameters parseCommandLine()
result.shouldDaemonize = true;
}
#endif
else {
//Uknown argument
result.uknownParameter = arg;
break;
}
}
else {
QFileInfo torrentPath;
torrentPath.setFile(arg);

Loading…
Cancel
Save