<artifactId>commons-csv</artifactId>
<version>1.3</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
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;
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;
}
/**
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() {
}
--- /dev/null
+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>'