diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-08 11:45:33 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-08 13:46:00 +0530 |
commit | a5058c11b6876b8ac3152052b22372488e7b5073 (patch) | |
tree | c50546964d1e94e235661140eaf3fa3e8aa096c5 | |
parent | b766ec88e50cd7c6d8ca1cd02622625b8c27f5e1 (diff) |
Add space for profile in normal mode
Issue-ID: CLI-95
Change-Id: I6d76d3097fe6ed7a25e35cad1effdd7c1b79eeb1
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
-rw-r--r-- | main/src/main/java/org/onap/cli/main/OnapCli.java | 26 |
1 files changed, 16 insertions, 10 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 aa1f1e7a..30db0703 100644 --- a/main/src/main/java/org/onap/cli/main/OnapCli.java +++ b/main/src/main/java/org/onap/cli/main/OnapCli.java @@ -139,15 +139,16 @@ public class OnapCli { */ public void handleProfile() { try { - if ((args.size() == 2) && (this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG).equals(args.get(0)) - || this.getShortOption(OnapCliConstants.PARAM_PROFILE_SHORT).equals(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), new ArrayList<String>(), new ArrayList<String>()); - //Make space of interactive mode - this.args = new ArrayList<>(); + //Make space of interactive mode/command mode + this.args.remove(0); //--profile or -c + this.args.remove(1); //profile name } } catch (Exception e) { this.print(e); @@ -224,7 +225,7 @@ public class OnapCli { if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_USE)) { if (args.size() == 1) { - this.print("Please input the product version to use, supported versions: " + + this.print("Please use it in the form of use <product-version>.\nSupported versions: " + OnapCommandRegistrar.getRegistrar().getAvailableProductVersions()); } else { try { @@ -234,20 +235,23 @@ public class OnapCli { this.print(e); } } + } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_HELP)) { try { this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion()); - this.print(this.getDirectiveHelp()); + this.print(OnapCli.getDirectiveHelp()); } catch (OnapCommandException e) { this.print(e); } + } 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>'\n"); - this.print("Profiles:"); + this.print("Profiles: "); this.print(OnapCommandRegistrar.getRegistrar().getUserProfiles().toString()); } else { this.args = Arrays.asList(new String [] { @@ -255,17 +259,19 @@ public class OnapCli { 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("="); - if (paramEntry.length >= 2) { + String [] paramEntry = args.get(1).trim().split("=", 2); + if (paramEntry.length == 2) { OnapCommandRegistrar.getRegistrar().addParamCache(paramEntry[0].trim(), paramEntry[1].trim()); } else { - this.print("Please use it in the form of 'set param-name=param-value'"); + this.print("Please use it in the form of 'set <param-name>=<param-value>'"); } } else { this.print(OnapCommandRegistrar.getRegistrar().getParamCache().toString()); } + } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_UNSET)) { if (args.size() > 1) { for (int i = 1; i <args.size(); i++) { |