aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-04-21 13:59:32 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-04-21 13:59:32 +0200
commit4edca6a80408037b4f753b44c460810a51489522 (patch)
treee816798a4d61ce12fce0a944dff49ce3f651b470 /src
parentRemove unneeded po::store (diff)
downloadsmolbote-4edca6a80408037b4f753b44c460810a51489522.tar.xz
Remove unknown option parsing
Diffstat (limited to 'src')
-rw-r--r--src/commandline.cpp12
-rw-r--r--src/commandline.h2
-rw-r--r--src/main.cpp20
3 files changed, 2 insertions, 32 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp
index bb636f2..f5e479c 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -88,18 +88,6 @@ void CommandLine::parseCommandLine(const QCoreApplication &app)
if(isSet(buildOption)) {
printBuild();
}
-
- // create a list of unknown QCommandLineOption's
- // parser.addOptions() takes a list, so this is a QList
-
- for(const QString &opt : unknownOptionNames()) {
- QCommandLineOption o(opt, "dummy desc", "dummy value");
- unknownOptions.append(o);
- }
-
- // add list and reparse to set the new options
- addOptions(unknownOptions);
- parse(app.arguments());
}
void CommandLine::printHelp(int exitCode)
diff --git a/src/commandline.h b/src/commandline.h
index 4229ac4..cb2f334 100644
--- a/src/commandline.h
+++ b/src/commandline.h
@@ -31,8 +31,6 @@ public:
const QCommandLineOption socketOption;
const QCommandLineOption newWindowOption;
- QList<QCommandLineOption> unknownOptions;
-
private:
QCoreApplication *application;
};
diff --git a/src/main.cpp b/src/main.cpp
index 1b4d26f..52df7ac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,24 +25,8 @@ int main(int argc, char **argv)
std::shared_ptr<Configuration> config = std::make_shared<Configuration>();
config->read(parser.value(parser.configOption));
- // parse command-line overrides
- // we assume the users knows what they're doing, so we only pass the unknown options to program_options
- // passing any unknown options though will cause it to fail, so we need to filter out the regular options
- // unfortunately, QCommandLineParser will only give us the unknown option
- // names, so we need to build a list, add them as options, reparse, and then
- // we get their values
- if(!parser.unknownOptions.isEmpty()) {
- int _argc = parser.unknownOptions.length() + 1;
- const char *_argv[_argc];
-
- // program_options requires 0 to be the program name, otherwise it seems to fail
- _argv[0] = qUtf8Printable(app.arguments().at(0));
-
- for(int i = 1; i < _argc; ++i) {
- _argv[i] = qUtf8Printable(QString("--%1=%2").arg(parser.unknownOptions[i - 1].names().at(0), parser.value(parser.unknownOptions[i - 1])));
- }
-
- config->parse(_argc, _argv);
+ if(!parser.unknownOptionNames().isEmpty()) {
+ qDebug("config->parse: %s", config->parse(argc, argv) ? "true" : "false");
}
app.setConfiguration(config);