diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-09 02:52:49 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-09 02:52:49 +0530 |
commit | b4723e06648181934eacec04fa987811a0b6f959 (patch) | |
tree | b139790b5241fa27181ef38c833d4ca2032d26e2 /main | |
parent | 16d3ea9a0229cbe22ac7729a97838141e3fab5d6 (diff) |
Improve map input parsing
Issue-ID: CLI-99
Change-Id: Ie78b3567d4542b8ea59d62b94d48a4351e803a5c
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/utils/OnapCliArgsParser.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java index 16d6a285..906d8d11 100644 --- a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java +++ b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java @@ -116,11 +116,13 @@ public class OnapCliArgsParser { paramMap.get(paramName).getName())); i++; continue; + } if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.TEXT)) { paramMap.get(paramName).setValue(readTextStringFromUrl(args.get(i + 1), paramMap.get(paramName).getName())); i++; continue; + } else if (paramMap.get(paramName).getParameterType() .equals(OnapCommandParameterType.ARRAY)) { Object value = paramMap.get(paramName).getValue(); @@ -130,16 +132,20 @@ public class OnapCliArgsParser { paramMap.get(paramName).setValue(list); i++; continue; - } else if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.MAP)) { + + } else if (paramMap.get(paramName).getParameterType() + .equals(OnapCommandParameterType.MAP)) { Object value = paramMap.get(paramName).getValue(); Map<String, String> map = (Map<String, String>) value; String arg = args.get(i + 1); - String[] argArr = arg.split("="); + String[] argArr = arg.split("=", 2); if (argArr.length != 2) { - throw new OnapCliInvalidArgument(paramMap.get(paramName).getName()); + throw new OnapCliInvalidArgument( + paramMap.get(paramName).getName(), + "it should be in the form of <key>=<value>"); } map.put(argArr[0], argArr[1]); @@ -157,7 +163,9 @@ public class OnapCliArgsParser { // it is positional option // Positional arg is missing from the params if (positionalIdx >= positionArgs.size()) { - throw new OnapCliInvalidArgument(args.get(i)); + throw new OnapCliInvalidArgument( + args.get(i), + "No positional argument is defined for this one"); } paramMap.get(positionArgs.get(positionalIdx)).setValue(args.get(i)); |