mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Detect uknown command line parameters.
This commit is contained in:
parent
8bfd333c60
commit
ca2dc325f5
1 changed files with 33 additions and 17 deletions
16
src/main.cpp
16
src/main.cpp
|
@ -114,6 +114,7 @@ struct QBtCommandLineParameters
|
||||||
#endif
|
#endif
|
||||||
int webUiPort;
|
int webUiPort;
|
||||||
QStringList torrents;
|
QStringList torrents;
|
||||||
|
QString uknownParameter;
|
||||||
|
|
||||||
QBtCommandLineParameters()
|
QBtCommandLineParameters()
|
||||||
: showHelp(false)
|
: showHelp(false)
|
||||||
|
@ -154,6 +155,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
const QBtCommandLineParameters params = parseCommandLine();
|
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
|
#ifndef Q_OS_WIN
|
||||||
if (params.showVersion) {
|
if (params.showVersion) {
|
||||||
if (isOneArg) {
|
if (isOneArg) {
|
||||||
|
@ -292,6 +299,9 @@ QBtCommandLineParameters parseCommandLine()
|
||||||
for (int i = 1; i < appArguments.size(); ++i) {
|
for (int i = 1; i < appArguments.size(); ++i) {
|
||||||
const QString& arg = appArguments[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"))) {
|
if ((arg == QLatin1String("-h")) || (arg == QLatin1String("--help"))) {
|
||||||
result.showHelp = true;
|
result.showHelp = true;
|
||||||
}
|
}
|
||||||
|
@ -314,6 +324,12 @@ QBtCommandLineParameters parseCommandLine()
|
||||||
result.shouldDaemonize = true;
|
result.shouldDaemonize = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else {
|
||||||
|
//Uknown argument
|
||||||
|
result.uknownParameter = arg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
QFileInfo torrentPath;
|
QFileInfo torrentPath;
|
||||||
torrentPath.setFile(arg);
|
torrentPath.setFile(arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue