aboutsummaryrefslogtreecommitdiff
path: root/src/commandline.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-03-06 16:06:32 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-03-06 16:06:32 +0100
commita16efaa441bad8cb687aa5aede82684998291c99 (patch)
treef17ef88b20bb40a5a8687018eb9c6ff6dd4e3936 /src/commandline.cpp
parentAdded poi-config (diff)
downloadsmolbote-a16efaa441bad8cb687aa5aede82684998291c99.tar.xz
Show local branch and commit in updater
Diffstat (limited to 'src/commandline.cpp')
-rw-r--r--src/commandline.cpp21
1 files changed, 18 insertions, 3 deletions
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<QCoreApplication *>(&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);
}