diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 36 |
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 |