From 4f8bc594e0bf21476aea79b4b916f12f31a12881 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 11 Sep 2017 19:29:00 +0530 Subject: Add profile support in interactive mode CLI-5 Change-Id: I993da7756b8495a2cc1205ad9085391c9212e54c Signed-off-by: Kanagaraj Manickam k00365106 --- main/src/main/java/org/onap/cli/main/OnapCli.java | 14 +++++++++++++- .../main/java/org/onap/cli/main/conf/OnapCliConstants.java | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'main/src') 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 '"); + } 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(){} -- cgit 1.2.3-korg