diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-10-12 19:30:55 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-11-20 14:07:57 +0530 |
commit | 81f15e39c42a2d86d590bbf1622bbd32434ad584 (patch) | |
tree | 072c4c647afeb083edbd209594fd538b8c3c145d /framework/src/main/java | |
parent | 2977f4f121a8527d97cb663482eb5134f67f921a (diff) |
Optimize version option output
Issue-Id: CLI-66
Change-Id: Ia64adb3e32de0dafc124ce1dbaf0204b43e9ffaf
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java | 26 | ||||
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/conf/Constants.java | 5 |
2 files changed, 18 insertions, 13 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java index e2d35654..1d2c5166 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java @@ -16,14 +16,17 @@ package org.onap.cli.fw; +import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.net.URISyntaxException; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.io.IOUtils; import org.onap.cli.fw.cmd.OnapHttpCommand; import org.onap.cli.fw.conf.Constants; import org.onap.cli.fw.conf.OnapCommandConfg; @@ -278,21 +281,18 @@ public class OnapCommandRegistrar { String configuredProductVersion = this.getEnabledProductVersion(); - String errorNote = ""; - String usageNote = "\n\nTo enable a product version, use one of following methods:" - + "\n 1. set env variable OPEN_CLI_PRODUCT_IN_USE" - + "\n 2. set cli.product.version in open-cli.properties" - + "\n 3. in interactive mode, use the directive 'use <product version>'\n"; - - if (!this.availableProductVersions.contains(configuredProductVersion)) { - errorNote = "** CUATION: Please configure the enabled product version to use one of " + this.availableProductVersions.toString() + "."; - + String versionInfo = ""; + try { + versionInfo = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream(Constants.VERSION_INFO)); + } catch (IOException e) { + //Never occurs // NOSONAR } - return "CLI version : " + version + buildTime + "\n" - + "Available product versions: " + this.availableProductVersions.toString() + "\n" - + "Enabled product version : " + configuredProductVersion + "\n" + - errorNote + usageNote; + versionInfo = versionInfo.replaceAll(Constants.VERSION_INFO_PLACE_HOLDER_ENB_PRD_VER, configuredProductVersion); + versionInfo = versionInfo.replaceAll(Constants.VERSION_INFO_PLACE_HOLDER_AVL_PRD_VER, this.availableProductVersions.toString()); + versionInfo = versionInfo.replaceAll(Constants.VERSION_INFO_PLACE_HOLDER_VERSION + "", version + buildTime); + + return versionInfo; } /** diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java index a43dec2b..bd416446 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java @@ -213,6 +213,11 @@ public class Constants { public static final String CATALOG_SERVICE_BASE_PATH = "catalog-service-base-path"; public static final String CATALOG_SERVICE_HOST_URL = "catalog-service-host-url"; + public static final String VERSION_INFO = "version.info"; + public static final String VERSION_INFO_PLACE_HOLDER_VERSION = "__VERSION__"; + public static final String VERSION_INFO_PLACE_HOLDER_AVL_PRD_VER = "__AVAILABLE_PRODUCT_VERSIONS__"; + public static final String VERSION_INFO_PLACE_HOLDER_ENB_PRD_VER = "__ENABLED_PRODUCT_VERSIONS__"; + private Constants() { } |