From 1eddb7418013e8405f6ff4834eb64396f3a29ff3 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 5 Dec 2018 12:00:13 +0100 Subject: Add builtins::version, ::build and ::help --- src/main.cpp | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index bb58782..e1e7618 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ */ #include "browser.h" +#include "builtins.h" #include "configuration.h" #include "session/session.h" #include "session/sessiondialog.h" @@ -88,11 +89,6 @@ int main(int argc, char **argv) // create and load configuration std::unique_ptr config = std::make_unique(nullptr); -#ifdef QT_DEBUG - QObject::connect(config.get(), &Configuration::settingChanged, [](const std::string &path, const QString &value) { - qDebug("!!! setting changed %s=[%s]", path.c_str(), qUtf8Printable(value)); - }); -#endif if(!config->parse(argc, argv)) { qWarning("Error parsing command line, check --help for usage."); @@ -104,15 +100,12 @@ int main(int argc, char **argv) // --version if(config->exists("version")) { - auto ver = QVersionNumber::fromString(QLatin1String(poi_Version)); - std::cout << "smolbote " << ver.toString().toStdString() << std::endl; - return 0; + return builtins::version(); } // --build if(config->exists("build")) { - std::cout << poi_Version << std::endl; - return 0; + return builtins::build(); } QVector plugins; @@ -137,27 +130,8 @@ int main(int argc, char **argv) } if(config->exists("help")) { - std::cout << "smolbote " << poi_Version << ": yet another no-frills browser" << std::endl; - std::cout << "Usage: " << argv[0] << " [options] [command/URL(s)]" << std::endl - << std::endl; - - std::cout << "Command-line Options: " << std::endl - << config->commandlineOptions() << std::endl; - - std::cout << "Commands: " << std::endl; - for(auto it = pluginCommands.constBegin(); it != pluginCommands.constEnd(); ++it) { - std::cout << it.key().toStdString() << std::endl; - } - std::cout << std::endl; - - std::cout << "Configuration Options: " << std::endl - << config->configurationOptions() << std::endl; -#ifdef Q_OS_LINUX - std::cout << std::endl - << "For more information refer to the manual page smolbote.7" << std::endl; -#endif - return 0; + return builtins::help(argv[0], config->commandlineOptions(), config->configurationOptions(), pluginCommands); } // argc, argv, allowSecondary -- cgit v1.2.1