aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java1
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java15
3 files changed, 10 insertions, 8 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
index 39204237..23d42f87 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
@@ -117,7 +117,7 @@ public class OnapCommandConstants {
public static final String DATA_PATH_PROFILE_JSON = "-profile.json";
public static final String DATA_PATH_PROFILE_JSON_PATTERN = DATA_DIRECTORY + "/**/*" + DATA_PATH_PROFILE_JSON;
public static final String DISCOVER_ALWAYS = "discover_always";
- public static final String PARAM_CACHE_FILE_NAME = "global-profile";
+ public static final String PARAM_CACHE_FILE_NAME = "default";
//normal
public static final String BASIC_SCHEMA_PROFILE = "basic";
diff --git a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
index 6669d965..19533ef7 100644
--- a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
+++ b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
@@ -140,6 +140,7 @@ public class OnapCommandParameterCache {
public void setProfile(String profileName) {
this.profileName = profileName;
+ this.paramCache.clear();
this.load();
}
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index 938497dd..7d907aa1 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -61,7 +61,7 @@ public class OnapCli {
private int exitCode = -1;
public OnapCli(String[] args) {
- this.args = Arrays.asList(args);
+ this.args.addAll(Arrays.asList(args));
}
public OnapCli(String product, String[] args) {
@@ -139,11 +139,11 @@ public class OnapCli {
*/
public void handleProfile() {
try {
- if ((this.args.size() == 2) && (this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG).equals(this.args.get(0))
+ if ((this.args.size() >= 2) && (this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG).equals(this.args.get(0))
|| this.getShortOption(OnapCliConstants.PARAM_PROFILE_SHORT).equals(this.args.get(0)))) {
OnapCommandRegistrar.getRegistrar().setProfile(
- args.get(1),
+ this.args.get(1),
new ArrayList<String>(),
new ArrayList<String>());
//Make space of interactive mode/command mode
@@ -221,7 +221,8 @@ public class OnapCli {
console.clearScreen();
continue;
}
- this.args = Arrays.asList(line.split(OnapCliConstants.PARAM_INTERACTIVE_ARG_SPLIT_PATTERN));
+ this.args.clear();
+ this.args.addAll(Arrays.asList(line.split(OnapCliConstants.PARAM_INTERACTIVE_ARG_SPLIT_PATTERN)));
if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_USE)) {
if (args.size() == 1) {
@@ -254,9 +255,7 @@ public class OnapCli {
this.print("Available profiles: ");
this.print(OnapCommandRegistrar.getRegistrar().getUserProfiles().toString());
} else {
- this.args = Arrays.asList(new String [] {
- this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG),
- this.args.get(1)});
+ this.args.set(0, this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG));
handleProfile();
}
@@ -326,6 +325,7 @@ public class OnapCli {
} catch (OnapCommandException e) { // NOSONAR
this.print("Failed to load oclip commands," + e.getMessage());
}
+
return console;
}
@@ -364,6 +364,7 @@ public class OnapCli {
}
}
+ //refer params from profile
for (OnapCommandParameter param: cmd.getParameters()) {
if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey(
cmd.getInfo().getService() + ":" + param.getLongOption())) {