From baf26eff73588b236d5c1261b462d76f8998838b Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Tue, 26 Sep 2017 11:30:31 +0530 Subject: Add commands help generation code CLI-34 Change-Id: Ic71c0a0d79ad4e1e1be74d5f98c3e1c40f300e2a Signed-off-by: Kanagaraj Manickam k00365106 --- .../org/onap/cli/fw/utils/OnapCommandUtils.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'framework/src') diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 2404a899..939c753a 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -1101,15 +1101,15 @@ public class OnapCommandUtils { if (param.getShortOption() != null || param.getLongOption() != null) { optFirstCol = OnapCommandParameter.printShortOption(param.getShortOption()) + " | " + OnapCommandParameter.printLongOption(param.getLongOption()); - commandOptions += "[" + optFirstCol + "] "; + commandOptions += " [" + optFirstCol + "]"; } else { optFirstCol = param.getName(); - commandOptions += "<" + optFirstCol + "> "; + commandOptions += " <" + optFirstCol + ">"; } newLineOptions++; - attrName.getValues().add(optFirstCol); + attrName.getValues().add(" " + optFirstCol); // Second column description String optSecondCol = param.getDescription().trim(); @@ -1142,7 +1142,7 @@ public class OnapCommandUtils { } try { - help += "\n\nOptions:\n" + commandOptions + "\nwhere,\n" + paramTable.print(); + help += "\n\nOptions::\n\n" + commandOptions + "\n\nwhere::\n\n" + paramTable.print(); } catch (OnapCommandException e) { throw new OnapCommandHelpFailed(e); } @@ -1156,7 +1156,7 @@ public class OnapCommandUtils { for (OnapCommandResultAttribute attr : cmd.getResult().getRecords()) { OnapCommandResultAttribute attrHelp = new OnapCommandResultAttribute(); - attrHelp.setName(attr.getName()); + attrHelp.setName(" " + attr.getName()); attrHelp.setDescription(attr.getDescription()); String msg = attr.getDescription() + " and is of type " + attr.getType().name() + "."; if (attr.isSecured()) { @@ -1166,14 +1166,17 @@ public class OnapCommandUtils { attrHelp.setType(attr.getType()); resultTable.getRecords().add(attrHelp); } - try { - help += "\n\nResults:\n" + resultTable.print(); - } catch (OnapCommandException e) { - throw new OnapCommandHelpFailed(e); + + if (cmd.getResult().getRecords().size() > 0) { + try { + help += "\n\nResults::\n\n" + resultTable.print(); + } catch (OnapCommandException e) { + throw new OnapCommandHelpFailed(e); + } } // Error - help += "\n\nError:\nOn error, it prints ::::\n"; + help += "\n\nError::\n\n On error, it prints ::::\n"; return help; } -- cgit 1.2.3-korg