From d867d642e06ad25fea7033ad268ed5deec9df87e Mon Sep 17 00:00:00 2001 From: hama Date: Sun, 31 Jul 2016 15:33:39 +0200 Subject: [PATCH] Client: -v option, pom.xml: scm --- pom.xml | 6 +++-- resources/jpinet.sh | 2 +- src/main/java/de/republib/pinet/Client.java | 27 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7e2ff0a..11b6f81 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 - de.republlb + de.republib pinet jar 1.0-SNAPSHOT @@ -13,7 +13,7 @@ https://sourcefourge.net scm:git:git@git.hamatoma.de:repo/jpinet - scm:svn:https://somerepository.com/svn_repo/trunk + scm:git:git@git.hamatoma.de:repo/jpinet http://somerepository.com/view.cvs @@ -142,6 +142,8 @@ de.republib.pinet.Client + true + true diff --git a/resources/jpinet.sh b/resources/jpinet.sh index 922a9af..e085037 100755 --- a/resources/jpinet.sh +++ b/resources/jpinet.sh @@ -14,7 +14,7 @@ if [ -z "$found" ] ; then echo "+++ missing pinet*-with-dependencies.jar" else echo "starting $full..." - java -jar $full de.republib.pinet.Client + java -jar $full $* fi diff --git a/src/main/java/de/republib/pinet/Client.java b/src/main/java/de/republib/pinet/Client.java index 670b856..1dc3ff4 100644 --- a/src/main/java/de/republib/pinet/Client.java +++ b/src/main/java/de/republib/pinet/Client.java @@ -1,5 +1,10 @@ package de.republib.pinet; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,6 +21,25 @@ public class Client { client.blink(PinNumber.PIN_RPi2_12, 10, 500, 500); } + public static String getVersion() { + String rc = null; + final InputStream resourceAsStream = Client.class.getResourceAsStream("/META-INF/MANIFEST.MF"); + final BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream)); + String line; + final String prefix = "Implementation-Version: "; + try { + while ((line = reader.readLine()) != null) { + if (line.startsWith(prefix)) { + rc = line.substring(prefix.length()).trim(); + break; + } + } + } catch (final IOException e) { + Client.logger.error("cannot read pom.properties['version']"); + } + return rc; + } + /** * Starts the graphical user interface client. * @@ -46,6 +70,9 @@ public class Client { if (arg.startsWith("-p") || arg.startsWith("--port=")) { arg = arg.substring(arg.charAt(1) == '-' ? 2 : 7); port = Integer.parseInt(arg); + } else if (arg.startsWith("-v") || arg.startsWith("--version")) { + System.out.println(Client.getVersion()); + System.exit(1); } } Client.gui(host, port); -- 2.39.5