summaryrefslogtreecommitdiffstats
path: root/framework/src
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java26
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java5
-rw-r--r--framework/src/main/resources/version.info7
3 files changed, 25 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() {
}
diff --git a/framework/src/main/resources/version.info b/framework/src/main/resources/version.info
new file mode 100644
index 00000000..34f4d969
--- /dev/null
+++ b/framework/src/main/resources/version.info
@@ -0,0 +1,7 @@
+CLI version : __VERSION__
+Available products: __AVAILABLE_PRODUCT_VERSIONS__
+Enabled product : __ENABLED_PRODUCT_VERSIONS__
+
+To enable a product , use one of following methods:
+1. In scripting mode, Set environment variable OPEN_CLI_PRODUCT_IN_USE
+2. In interactive mode, set the directive 'use <product>'