diff options
Diffstat (limited to 'framework/src/main/java/org/onap')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java | 16 | ||||
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java | 18 |
2 files changed, 15 insertions, 19 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java index 4b7fe976..09e1927a 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java @@ -166,18 +166,16 @@ public abstract class OnapCommand { // -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 @@ -225,7 +223,7 @@ public abstract class OnapCommand { * @return version */ public String printVersion() { - return this.getInfo().getService(); + return this.getInfo().getProduct() + "::" + this.getInfo().getService(); } /** diff --git a/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java b/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java index 4eaab81a..3544fd7c 100644 --- a/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java +++ b/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java @@ -181,10 +181,10 @@ public class OnapCommandResult { * 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(); @@ -220,16 +220,14 @@ public class OnapCommandResult { 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()); |