// -h or --help is always higher precedence !, user can set this value to get help message
if (OnapCommandConstants.BOOLEAN_TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_HELP).getValue())) {
- OnapCommandResult result = new OnapCommandResult();
- result.setType(OnapCommandResultType.TEXT);
- result.setOutput(this.printHelp());
- return result;
+ this.cmdResult.setType(OnapCommandResultType.TEXT);
+ this.cmdResult.setOutput(this.printHelp());
+ return this.cmdResult;
}
// -v or --version is next higher precedence !, user can set this value to get help message
if (OnapCommandConstants.BOOLEAN_TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_VERSION).getValue())) {
- OnapCommandResult result = new OnapCommandResult();
- result.setType(OnapCommandResultType.TEXT);
- result.setOutput(this.printVersion());
- return result;
+ this.cmdResult.setType(OnapCommandResultType.TEXT);
+ this.cmdResult.setOutput(this.printVersion());
+ return this.cmdResult;
}
// validate
* @return version
*/
public String printVersion() {
- return this.getInfo().getService();
+ return this.getInfo().getProduct() + "::" + this.getInfo().getService();
}
/**
* exception
*/
public String print() throws OnapCommandException {
- String printOutput = "";
-
if (this.getRecords().isEmpty()) {
- return printOutput;
+ return "";
+ } else if (this.getType().equals(OnapCommandResultType.TEXT)) {
+ return this.getOutput().toString();
}
OnapCommandPrint print = new OnapCommandPrint();
print.addColumn(val.getName(), val.getValues());
}
- if (this.isDebug()) {
- printOutput = this.getDebugInfo() + "\n";
- }
-
if (this.getType().equals(OnapCommandResultType.JSON)) {
- return printOutput + print.printJson();
+ return print.printJson();
} else if (this.getType().equals(OnapCommandResultType.TABLE)) {
- return printOutput + print.printTable(this.isIncludeSeparator());
+ return print.printTable(this.isIncludeSeparator());
} else if (this.getType().equals(OnapCommandResultType.CSV)) {
- return printOutput + print.printCsv();
+ return print.printCsv();
+ } else if (this.getType().equals(OnapCommandResultType.YAML)) {
+ return print.printYaml();
}
throw new OnapCommandOutputFormatNotsupported(this.getType().name());