From a16efaa441bad8cb687aa5aede82684998291c99 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 6 Mar 2018 16:06:32 +0100 Subject: Show local branch and commit in updater --- src/commandline.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/commandline.cpp') diff --git a/src/commandline.cpp b/src/commandline.cpp index ffd7957..e7eec5d 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -48,6 +48,7 @@ CommandLine::CommandLine() : QCommandLineParser() , helpOption(addHelpOption()) , versionOption(addVersionOption()) + , buildOption("build", "Show build information.") , configOption({ "c", "config" }, "Set configuration file.", "path", defaultUserConfigLocation()) , defaultConfigOption("default-config", "Set the default configuration file.", "path", "") , profileOption({ "p", "profile" }, "Use this profile.", "profile", "") @@ -56,6 +57,7 @@ CommandLine::CommandLine() { setApplicationDescription("yet another no-frills browser"); + addOption(buildOption); addOption(configOption); addOption(defaultConfigOption); addOption(profileOption); @@ -72,13 +74,17 @@ void CommandLine::parseCommandLine(const QCoreApplication &app) application = const_cast(&app); if(isSet(helpOption)) { - printHelp(0); + printHelp(); } if(isSet(versionOption)) { printVersion(); } + if(isSet(buildOption)) { + printBuild(); + } + // create a list of unknown QCommandLineOption's // parser.addOptions() takes a list, so this is a QList @@ -91,6 +97,7 @@ void CommandLine::parseCommandLine(const QCoreApplication &app) addOptions(unknownOptions); parse(app.arguments()); } + void CommandLine::printHelp(int exitCode) { std::cout << "Usage: " << application->arguments().at(0).toStdString() << " [options] URL" << std::endl; @@ -101,6 +108,7 @@ void CommandLine::printHelp(int exitCode) std::cout << "Options: " << std::endl; printOption(helpOption); printOption(versionOption); + printOption(buildOption); printOption(configOption); printOption(defaultConfigOption); printOption(profileOption); @@ -121,8 +129,15 @@ void CommandLine::printHelp(int exitCode) exit(exitCode); } -void CommandLine::printVersion() + +void CommandLine::printVersion(int exitCode) { std::cout << application->applicationName().toStdString() << " " << SMOLBOTE_DESCRIBE << std::endl; - exit(0); + exit(exitCode); +} + +void CommandLine::printBuild(int exitCode) +{ + std::cout << SMOLBOTE_BRANCH << ":" << SMOLBOTE_COMMIT << std::endl; + exit(exitCode); } -- cgit v1.2.1