aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-05-15 19:17:51 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-05-15 19:17:51 +0200
commite43cf73d33d731b5d817d98c3dcb3d66eba1f718 (patch)
tree20a2d826c95761d8317104c92e66be085a977a5e /src/main.cpp
parentProfile editor plugin (diff)
downloadsmolbote-e43cf73d33d731b5d817d98c3dcb3d66eba1f718.tar.xz
Move help and version functions to main (out of Configuration)
Make loading profiles a free function in Browser
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 548aec8..f1ac1ae 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,30 +7,46 @@
*/
#include "browser.h"
-#include "mainwindow/mainwindow.h"
#include "version.h"
-#include "webengine/webprofile.h"
+#include <QFile>
#include <configuration/configuration.h>
#include <memory>
-#include <QFile>
+#include <iostream>
int main(int argc, char **argv)
{
- Browser app(argc, argv);
-
- // set this, otherwise the webview becomes black when using a stylesheet
- app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
-
// create and load configuration
std::shared_ptr<Configuration> config = std::make_shared<Configuration>();
- if(!config->parseCommandLine(argc, argv)) {
+ if(!config->parse(argc, argv)) {
qWarning("Check --help for usage.");
return -1;
}
- if(!config->parseConfigFile(config->value<std::string>("config").value())) {
+ if(!config->parse(config->value<std::string>("config").value())) {
qWarning("Error parsing config file.");
}
+ if(config->exists("help")) {
+ std::cout << "smolbote " << SMOLBOTE_VERSION << ": yet another no-frills browser" << std::endl;
+ std::cout << "Usage: " << argv[0] << " [options] URL(s)" << std::endl;
+
+ std::cout << std::endl << "Command-line Options: " << std::endl << config->commandlineOptions() << std::endl;
+ std::cout << std::endl << "Configuration Options: " << std::endl << config->configurationOptions() << std::endl;
+ return 0;
+ }
+
+ if(config->exists("version")) {
+ std::cout << "smolbote " << SMOLBOTE_VERSION << std::endl;
+ return 0;
+ }
+
+ if(config->exists("build")) {
+ std::cout << SMOLBOTE_BRANCH << ":" << SMOLBOTE_COMMIT;
+ return 0;
+ }
+
+ Browser app(argc, argv);
+ // set this, otherwise the webview becomes black when using a stylesheet
+ app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
app.setConfiguration(config);
// set up socket