aboutsummaryrefslogtreecommitdiff
path: root/src
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
parentAdded poi-config (diff)
downloadsmolbote-a16efaa441bad8cb687aa5aede82684998291c99.tar.xz
Show local branch and commit in updater
Diffstat (limited to 'src')
-rw-r--r--src/commandline.cpp21
-rw-r--r--src/commandline.h4
-rw-r--r--src/version.h.in3
3 files changed, 24 insertions, 4 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);
}
diff --git a/src/commandline.h b/src/commandline.h
index 81063d3..d7416b7 100644
--- a/src/commandline.h
+++ b/src/commandline.h
@@ -18,10 +18,12 @@ public:
void parseCommandLine(const QCoreApplication &app);
void printHelp(int exitCode = 0);
- void printVersion();
+ void printVersion(int exitCode = 0);
+ void printBuild(int exitCode = 0);
const QCommandLineOption helpOption;
const QCommandLineOption versionOption;
+ const QCommandLineOption buildOption;
const QCommandLineOption configOption;
const QCommandLineOption defaultConfigOption;
diff --git a/src/version.h.in b/src/version.h.in
index 88008cf..2e6ecf2 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -7,6 +7,9 @@
// Describe: 1.2.3-r123-0123456789ab
#define SMOLBOTE_DESCRIBE "@VcsVersion@-r@VcsRevision@-@VcsCommit@"
+// Commit
+#define SMOLBOTE_COMMIT "@VcsCommit@"
+
// Branch: default
#define SMOLBOTE_BRANCH "@VcsBranch@"