aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commandline.cpp21
-rw-r--r--src/commandline.h4
-rw-r--r--src/version.h.in3
-rw-r--r--tools/updater/main.go23
4 files changed, 38 insertions, 13 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@"
diff --git a/tools/updater/main.go b/tools/updater/main.go
index e5e377c..eda229b 100644
--- a/tools/updater/main.go
+++ b/tools/updater/main.go
@@ -30,16 +30,17 @@ func branchmap(repository string) (branches map[string]string, err error) {
return
}
-func poi(executable string) (version string, err error) {
- cmd := exec.Command(executable, "--version")
+func poi(executable string) (version string, commit string, err error) {
+ cmd := exec.Command(executable, "--build")
// wait for complete
err = cmd.Wait()
// return output
output, err := cmd.Output()
- v := strings.Split(string(output), "-")
- version = v[len(v)-1]
+ v := strings.Split(string(output), ":")
+ version = v[0]
+ commit = v[1]
return
}
@@ -57,17 +58,21 @@ func main() {
os.Exit(0)
}
- fmt.Println("Getting poi --version")
- poi_version, err := poi(*execFlag)
+ fmt.Println("Getting poi build...")
+ if *verboseFlag {
+ fmt.Println("[exec =", *execFlag, "]")
+ }
+
+ poi_branch, poi_commit, err := poi(*execFlag)
if err != nil {
fmt.Println("error:", err)
}
- fmt.Println(poi_version)
+ fmt.Println("-", poi_branch, ":", poi_commit)
// get branchmap
fmt.Println("Getting branchmap...")
if *verboseFlag {
- fmt.Println("for repository", *repoFlag)
+ fmt.Println("[repo =", *repoFlag, "]")
}
branches, err := branchmap(*repoFlag)
@@ -77,7 +82,7 @@ func main() {
}
for branch, commit := range branches {
- fmt.Println("-", branch, ":", commit[0:len(poi_version)-1])
+ fmt.Println("-", branch, ":", commit[0:12])
}
}