diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-26 23:09:31 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-26 23:09:31 +0100 |
commit | fcf3870b7c0f30a5991e518ad8a404a9d38c3a45 (patch) | |
tree | 3168f904fb2dd205ce1fbbac2daa0f381ec86b70 /src/main.cpp | |
parent | Added warning when trying to get value of non-existent options (diff) | |
download | smolbote-fcf3870b7c0f30a5991e518ad8a404a9d38c3a45.tar.xz |
Using boost::program_options instead of libconfig
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index cce2c61..70f22be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,6 @@ int main(int argc, char **argv) // default config, :/poi.cfg QCommandLineOption defaultConfigOption("default-config", "Set the default configuration file.", "path"); - defaultConfigOption.setDefaultValue(":/poi.cfg"); parser.addOption(defaultConfigOption); QCommandLineOption profileOption({ "p", "profile" }, "Use this profile.", "PROFILE"); @@ -76,14 +75,20 @@ int main(int argc, char **argv) qDebug("profile=%s", qUtf8Printable(parser.value(profileOption))); #endif - std::shared_ptr<Configuration> config = std::make_shared<Configuration>( - parser.value(configOption).toStdString(), - QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); + std::shared_ptr<Configuration> config = std::make_shared<Configuration>(); // first load the default configuration - config->read(parser.value(defaultConfigOption)); + if(parser.isSet(defaultConfigOption)) { + qDebug("Reading default configuration [%s]: %s", + qUtf8Printable(parser.value(defaultConfigOption)), + config->read(parser.value(defaultConfigOption)) ? "ok" : "failed"); + } // then load in the user configuration, which will overwrite it - config->read(parser.value(configOption)); + if(parser.isSet(configOption)) { + qDebug("Reading configuration [%s]: %s", + qUtf8Printable(parser.value(configOption)), + config->read(parser.value(configOption)) ? "ok" : "failed"); + } // check for other instances // if we socket hasn't been disabled (socket is not none) |