From 881f9a6d2358f36f3496ca19875140fe2090a483 Mon Sep 17 00:00:00 2001 From: SimMac Date: Thu, 31 Mar 2016 21:01:08 +0200 Subject: [PATCH] Implemented version command (usage `java -jar threema-msgapi-tool.jar -v`) with feature level. --- README.md | 16 ++++++- source/pom.xml | 8 ++++ .../java/ch/threema/apitool/ConsoleMain.java | 4 +- .../console/commands/VersionCommand.java | 43 +++++++++++++++++++ source/src/main/resources/app.properties | 2 + 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 source/src/main/java/ch/threema/apitool/console/commands/VersionCommand.java create mode 100644 source/src/main/resources/app.properties diff --git a/README.md b/README.md index c74b863..1b13e5f 100644 --- a/README.md +++ b/README.md @@ -62,4 +62,18 @@ Fetch the capability of a Threema ID ####Decrypt and download java -jar threema-msgapi-tool.jar -D [outputFolder] -Decrypt a box (box from the stdin) message and download (if the message is a image or file message) the file(s) to the defined directory \ No newline at end of file +Decrypt a box (box from the stdin) message and download (if the message is a image or file message) the file(s) to the defined directory + +## Feature Levels + +| Level | Text | Capabilities | Image | File | Credits | +|-------|------|--------------|-------|------|---------| +| 1 | X | | | | | +| 2 | X | X | X | X | | +| 3 | X | X | X | X | X | + +You can see the implemented feature level by invoking the following command: + +``` +$ java -jar threema-msgapi-tool.jar -v +``` diff --git a/source/pom.xml b/source/pom.xml index d1d30c9..3408584 100644 --- a/source/pom.xml +++ b/source/pom.xml @@ -12,6 +12,7 @@ UTF-8 ${source.encoding} ${source.encoding} + 3 @@ -55,6 +56,13 @@ + + + src/main/resources + true + + + org.apache.maven.plugins diff --git a/source/src/main/java/ch/threema/apitool/ConsoleMain.java b/source/src/main/java/ch/threema/apitool/ConsoleMain.java index 469e815..b54dfd2 100644 --- a/source/src/main/java/ch/threema/apitool/ConsoleMain.java +++ b/source/src/main/java/ch/threema/apitool/ConsoleMain.java @@ -127,7 +127,9 @@ public static void main(String[] args) throws Exception { .add(new HashEmailCommand(), "-h", "-e") .add(new HashPhoneCommand(), "-h", "-p") .add(new GenerateKeyPairCommand(), "-g") - .add(new DerivePublicKeyCommand(), "-p"); + .add(new DerivePublicKeyCommand(), "-p") + .add(new VersionCommand(), "-v"); + commands.create("Network operations") .add(new SendSimpleMessageCommand(), "-s") diff --git a/source/src/main/java/ch/threema/apitool/console/commands/VersionCommand.java b/source/src/main/java/ch/threema/apitool/console/commands/VersionCommand.java new file mode 100644 index 0000000..37e33c2 --- /dev/null +++ b/source/src/main/java/ch/threema/apitool/console/commands/VersionCommand.java @@ -0,0 +1,43 @@ +/* + * $Id$ + * + * The MIT License (MIT) + * Copyright (c) 2016 Threema GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE + */ + +package ch.threema.apitool.console.commands; + +import java.io.InputStream; +import java.util.Properties; + +public class VersionCommand extends Command { + + public VersionCommand() { + super("Version", "Prints the current version and feature level. "); + } + + @Override + protected void execute() throws Exception { + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("app.properties"); + Properties p = new Properties(); + p.load(inputStream); + System.out.println("Version: "+p.getProperty("version")+"\nFeature level: "+p.getProperty("feature.level")); + } +} diff --git a/source/src/main/resources/app.properties b/source/src/main/resources/app.properties new file mode 100644 index 0000000..0602332 --- /dev/null +++ b/source/src/main/resources/app.properties @@ -0,0 +1,2 @@ +version=${project.version} +feature.level=${property.featureLevel} \ No newline at end of file