aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-11 19:29:00 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-11 19:29:16 +0530
commit4f8bc594e0bf21476aea79b4b916f12f31a12881 (patch)
tree94a3d6aa12185104aa993cd5d3931df3033b50ee /main
parentee757a5761156fcbcff3d0bd4f6e75bb0931d536 (diff)
Add profile support in interactive mode
CLI-5 Change-Id: I993da7756b8495a2cc1205ad9085391c9212e54c Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java14
-rw-r--r--main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java3
2 files changed, 16 insertions, 1 deletions
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 71d9cf77..8a4ebeb1 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -175,6 +175,8 @@ public class OnapCli {
attr.getValues().add(OnapCliConstants.PARAM_INTERACTIVE_HELP);
attrDesc.getValues().add(OnapCliConstants.PARAM_INTERACTIVE_HELP_MSG);
+ attr.getValues().add(OnapCliConstants.PARAM_INTERACTIVE_PROFILE);
+ attrDesc.getValues().add(OnapCliConstants.PARAM_INTERACTIVE_PROFILE_MSG);
try {
return "\n\nDirectives:\n" + help.print();
} catch (OnapCommandException e) {
@@ -224,6 +226,15 @@ public class OnapCli {
} else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_VERSION)) {
this.args = Arrays.asList(new String [] {this.getLongOption(OnapCliConstants.PARAM_VERSION_LONG)});
handleVersion();
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_PROFILE)) {
+ if (args.size() == 1) {
+ this.print("Please use it in the form of 'profile <profile-name>'");
+ } else {
+ this.args = Arrays.asList(new String [] {
+ this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG),
+ this.args.get(1)});
+ handleProfile();
+ }
} else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_SET)) {
if (args.size() > 1) {
String [] paramEntry = args.get(1).trim().split("=");
@@ -285,7 +296,8 @@ public class OnapCli {
OnapCliConstants.PARAM_INTERACTIVE_HELP,
OnapCliConstants.PARAM_INTERACTIVE_VERSION,
OnapCliConstants.PARAM_INTERACTIVE_SET,
- OnapCliConstants.PARAM_INTERACTIVE_UNSET);
+ OnapCliConstants.PARAM_INTERACTIVE_UNSET,
+ OnapCliConstants.PARAM_INTERACTIVE_PROFILE);
console.addCompleter(strCompleter);
console.setPrompt(OnapCliConstants.PARAM_INTERACTIVE_PROMPT);
} catch (OnapCommandException e) { // NOSONAR
diff --git a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
index 337cd41c..d28b9849 100644
--- a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
+++ b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
@@ -45,6 +45,9 @@ public final class OnapCliConstants {
public static final String PARAM_INTERACTIVE_SET_MSG = "To set the parameter values. Once its set, will be available for all commands in current session.";
public static final String PARAM_INTERACTIVE_UNSET = "unset";
public static final String PARAM_INTERACTIVE_UNSET_MSG = "To unset the parameter value in current session.";
+ public static final String PARAM_INTERACTIVE_PROFILE = "profile";
+ public static final String PARAM_INTERACTIVE_PROFILE_MSG = "Start profiling current settings made of use, set.";
+
public static final String PARAM_INTERACTIVE_ARG_SPLIT_PATTERN = "\\s+";
private OnapCliConstants(){}