summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java11
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java13
2 files changed, 23 insertions, 1 deletions
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 3544fd7c..0b9f9be7 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
@@ -171,6 +171,17 @@ public class OnapCommandResult {
this.isDebug = isDebug;
}
+ public int getNumberOfRows() {
+ int noOfRecords = 0;
+
+ for (OnapCommandResultAttribute cols : this.records) {
+ if (cols != null && noOfRecords < cols.getValues().size()) {
+ noOfRecords = cols.getValues().size();
+ }
+ }
+
+ return noOfRecords;
+ }
/**
* Helps to print the result based on the type.
*
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index 149fd955..65edfc13 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -56,12 +56,19 @@ public class OnapCli {
private List<String> args = new ArrayList<>();
+ private String product = null;
+
private int exitCode = -1;
public OnapCli(String[] args) {
this.args = Arrays.asList(args);
}
+ public OnapCli(String product, String[] args) {
+ this(args);
+ this.product = product;
+ }
+
private void exitSuccessfully() {
this.exitCode = OnapCliConstants.EXIT_SUCCESS;
}
@@ -323,7 +330,11 @@ public class OnapCli {
OnapCommand cmd;
if (!args.isEmpty()) {
try {
- cmd = OnapCommandRegistrar.getRegistrar().get(args.get(0));
+ if (this.product != null) {
+ cmd = OnapCommandRegistrar.getRegistrar().get(args.get(0), this.product);
+ } else {
+ cmd = OnapCommandRegistrar.getRegistrar().get(args.get(0));
+ }
} catch (Exception e) {
this.print(e);
this.exitFailure();