You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/12/08 09:09:30 UTC

[camel] branch main updated: camel-jbang - camel get count

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 08c10d09ed5 camel-jbang - camel get count
08c10d09ed5 is described below

commit 08c10d09ed5ffd1fc02e08ee631474414a327f55
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 8 10:09:21 2022 +0100

    camel-jbang - camel get count
---
 .../dsl/jbang/core/commands/CamelJBangMain.java    |  2 +-
 .../jbang/core/commands/process/CamelCount.java    | 36 ++++++++++------------
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index c9db98d9bf1..49ed050991b 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -78,6 +78,7 @@ public class CamelJBangMain implements Callable<Integer> {
                         .addSubcommand("context", new CommandLine(new CamelContextStatus(main)))
                         .addSubcommand("route", new CommandLine(new CamelRouteStatus(main)))
                         .addSubcommand("processor", new CommandLine(new CamelProcessorStatus(main)))
+                        .addSubcommand("count", new CommandLine(new CamelCount(main)))
                         .addSubcommand("health", new CommandLine(new ListHealth(main)))
                         .addSubcommand("endpoint", new CommandLine(new CamelEndpointStatus(main)))
                         .addSubcommand("event", new CommandLine(new ListEvent(main)))
@@ -89,7 +90,6 @@ public class CamelJBangMain implements Callable<Integer> {
                         .addSubcommand("service", new CommandLine(new ListService(main)))
                         .addSubcommand("source", new CommandLine(new CamelSourceAction(main)))
                         .addSubcommand("vault", new CommandLine(new ListVault(main))))
-                .addSubcommand("count", new CommandLine(new CamelCount(main)))
                 .addSubcommand("top", new CommandLine(new CamelTop(main))
                         .addSubcommand("context", new CommandLine(new CamelContextTop(main)))
                         .addSubcommand("route", new CommandLine(new CamelRouteTop(main)))
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelCount.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelCount.java
index eae51dfe99c..69515307887 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelCount.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelCount.java
@@ -102,30 +102,28 @@ public class CamelCount extends ProcessBaseCommand {
             }
         } else {
             StringBuilder builder = new StringBuilder();
-            if (total || fail) {
-                if (!rows.isEmpty()) {
-                    int index = 0;
-                    for (Row r : rows) {
-                        if (rows.size() > 1) {
-                            builder.append(r.name).append(",");
-                        }
+            if (!rows.isEmpty()) {
+                int index = 0;
+                for (Row r : rows) {
+                    if (rows.size() > 1) {
+                        builder.append(r.name).append(",");
+                    }
+                    if (total) {
+                        builder.append(r.total);
+                    }
+                    if (fail) {
                         if (total) {
-                            builder.append(r.total);
+                            builder.append(",");
                         }
-                        if (fail) {
-                            if (total) {
-                                builder.append(",");
-                            }
-                            builder.append(r.failed);
-                        }
-                        if (index < rows.size() - 1) {
-                            builder.append(System.getProperty("line.separator"));
-                        }
-                        index++;
+                        builder.append(r.failed);
+                    }
+                    if (index < rows.size() - 1) {
+                        builder.append(System.getProperty("line.separator"));
                     }
+                    index++;
                 }
             }
-            System.out.println(builder.toString());
+            System.out.println(builder);
         }
 
         return 0;