Add profile support in interactive mode 81/11681/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 11 Sep 2017 13:59:00 +0000 (19:29 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 11 Sep 2017 13:59:16 +0000 (19:29 +0530)
CLI-5
Change-Id: I993da7756b8495a2cc1205ad9085391c9212e54c
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
main/src/main/java/org/onap/cli/main/OnapCli.java
main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java

index 71d9cf7..8a4ebeb 100644 (file)
@@ -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
index 337cd41..d28b984 100644 (file)
@@ -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(){}