aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-26 11:30:31 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-26 11:35:12 +0530
commitbaf26eff73588b236d5c1261b462d76f8998838b (patch)
tree619604c8eef8c39c67765ef6a10fc3cd9815423b /framework/src
parentcd0acb805f22c079cb5b94961a73200b1acac780 (diff)
Add commands help generation code
CLI-34 Change-Id: Ic71c0a0d79ad4e1e1be74d5f98c3e1c40f300e2a Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java23
1 files changed, 13 insertions, 10 deletions
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 <HTTP STATUS CODE>::<ERROR CODE>::<ERROR MESSAGE>\n";
+ help += "\n\nError::\n\n On error, it prints <HTTP STATUS CODE>::<ERROR CODE>::<ERROR MESSAGE>\n";
return help;
}