summaryrefslogtreecommitdiffstats
path: root/framework/src
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java16
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java18
-rw-r--r--framework/src/main/resources/open-cli-schema/default_input_parameters.yaml4
3 files changed, 17 insertions, 21 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());
diff --git a/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml b/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
index e8e08f46..02e8a717 100644
--- a/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
+++ b/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
@@ -7,13 +7,13 @@ info:
parameters:
- name: help
- type: string
+ type: bool
description: print help message
short_option: h
long_option: help
default_value: false
- name: version
- type: string
+ type: bool
description: print service version
short_option: v
long_option: version