aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-04 21:12:06 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-04 21:19:34 +0200
commitf65d6ea0d7ca7de7a6c7538612731b11889086fb (patch)
treeb459e38149232f098bdc6fff322b95d2c4e462bf /src
parentPKGBUILD: add install stage for debug symbols (diff)
downloadsmolbote-f65d6ea0d7ca7de7a6c7538612731b11889086fb.tar.xz
Fix configuration not being read unless explicitly specified
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp35
-rw-r--r--src/settings.h.in15
2 files changed, 15 insertions, 35 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f6a5b17..be6a559 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,14 +38,6 @@ inline std::string join_keys(const command_map &map, const std::string sep = ",
return k;
}
-#if defined(CONFIG_USEPLASMA) && !defined(PLASMA)
-#error "You have enabled Plasma integration, but Frameworks was not found."
-#endif
-
-#if defined(CONFIG_USEBREAKPAD) && !defined(BREAKPAD)
-#error "You have enabled Breakpad integration, but Breakpad was not found."
-#endif
-
int main(int argc, char **argv)
{
// change log pattern
@@ -54,20 +46,14 @@ int main(int argc, char **argv)
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
#endif
- const std::vector<std::string> args(argv + 1, argv + argc);
- args::ArgumentParser parser("smolbote: yet another no-frills browser",
-#ifdef Q_OS_UNIX
- "For more information on usage, refer to the manual page."
-#else
- "For more information on usage, refer to the manual."
-#endif
- );
- parser.Prog(argv[0]);
-
const command_map commands{
{ "configuration", builtins::configuration }
};
+ const std::vector<std::string> args(argv + 1, argv + argc);
+ args::ArgumentParser parser("smolbote: yet another no-frills browser", "Subcommands: " + join_keys(commands));
+ parser.Prog(argv[0]);
+
args::HelpFlag cmd_help(parser, "help", "Display this help message.", { 'h', "help" });
args::Flag cmd_version(parser, "version", "Display version information.", { 'v', "version" });
args::Flag cmd_build(parser, "build", "Display build commit.", { 'b', "build" });
@@ -91,7 +77,7 @@ int main(int argc, char **argv)
return builtins::build();
// create and load configuration
- init_conf(args::get(cmd_config));
+ spdlog::info("Loading configuration {}", init_conf(args::get(cmd_config)));
if(cmd_args) {
const auto front = args::get(cmd_args).front();
@@ -101,10 +87,8 @@ int main(int argc, char **argv)
}
}
- } catch(args::Help &e) {
+ } catch(args::Help &) {
std::cout << parser;
- Q_UNUSED(e);
- std::cout << "Available subcommands: " << join_keys(commands) << std::endl;
return 0;
} catch(args::Error &e) {
@@ -113,13 +97,6 @@ int main(int argc, char **argv)
return -1;
}
- // Disable Chromium's crash handler so breakpad can capture crashes instead.
- // This has to be done before QtWebEngine gets initialized.
- const auto chromiumFlags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
- if(!chromiumFlags.contains("disable-in-process-stack-traces")) {
- qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromiumFlags + " --disable-in-process-stack-traces");
- }
-
QVector<QPluginLoader *> plugins;
CommandHash_t pluginCommands;
diff --git a/src/settings.h.in b/src/settings.h.in
index a4b5159..88fbcf5 100644
--- a/src/settings.h.in
+++ b/src/settings.h.in
@@ -4,26 +4,29 @@
#include <configuration.h>
#include <fstream>
-inline void init_conf(const std::string &path)
+inline const std::string init_conf(const std::string &path)
{
+ auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
+ @__DEFAULT_CFG__
+ });
const std::string cfgpath = [&]() {
+ if(path.empty())
+ return value_map->value<std::string>("poi.cfg.path").value();
+
auto p = path;
if(p.front() == '~')
p.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString());
return p;
}();
- auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
- @__DEFAULT_CFG__
- });
-
std::fstream fs;
- fs.open(path, std::fstream::in);
+ fs.open(cfgpath, std::fstream::in);
if(fs.is_open()) {
value_map->read(fs);
fs.close();
}
Configuration::move_global(std::move(value_map));
+ return cfgpath;
}