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/08/24 14:41:33 UTC

[camel] branch main updated (f807080d880 -> 4401dad9d80)

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

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


    from f807080d880 CAMEL-18406: camel-jbang - Status command
     new 9442b88060c CAMEL-18406: camel-jbang - Status command
     new 4401dad9d80 CAMEL-18406: camel-jbang - Status command

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/commands/process/CamelContextStatus.java  | 22 ++++++++-------
 .../core/commands/process/CamelRouteStatus.java    | 32 +++++++++++-----------
 .../core/commands/process/ProcessBaseCommand.java  | 23 ++++++++++++++--
 3 files changed, 48 insertions(+), 29 deletions(-)


[camel] 01/02: CAMEL-18406: camel-jbang - Status command

Posted by da...@apache.org.
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

commit 9442b88060cf3c72c62dbae6b8668fab46c97cec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Aug 24 16:20:32 2022 +0200

    CAMEL-18406: camel-jbang - Status command
---
 .../core/commands/process/CamelContextStatus.java  | 22 ++++++++-------
 .../core/commands/process/CamelRouteStatus.java    | 32 +++++++++++-----------
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
index b25bc758c64..e78aa8bb8d4 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
@@ -30,6 +30,7 @@ import com.github.freva.asciitable.HorizontalAlign;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.TimeUtils;
 import org.apache.camel.util.json.JsonObject;
 import org.apache.camel.util.json.Jsoner;
@@ -99,17 +100,18 @@ public class CamelContextStatus extends ProcessBaseCommand {
                 });
 
         if (!rows.isEmpty()) {
-            System.out.println(AsciiTable.getTable(AsciiTable.BASIC_ASCII_NO_DATA_SEPARATORS, rows, Arrays.asList(
-                    new Column().header("PID").with(r -> r.pid),
-                    new Column().header("Name").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
+            System.out.println(AsciiTable.getTable(AsciiTable.NO_BORDERS, rows, Arrays.asList(
+                    new Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
+                    new Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
                             .with(r -> maxWidth(r.name, 28)),
-                    new Column().header("Ready").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
-                    new Column().header("State").with(r -> r.state),
-                    new Column().header("Age").with(r -> r.ago),
-                    new Column().header("Total").with(r -> r.total),
-                    new Column().header("Failed").with(r -> r.failed),
-                    new Column().header("Inflight").with(r -> r.inflight),
-                    new Column().header("Last Ago").with(r -> r.sinceLast))));
+                    new Column().header("READY").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
+                    new Column().header("STATE").headerAlign(HorizontalAlign.CENTER)
+                            .with(r -> StringHelper.capitalize(r.state)),
+                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.ago),
+                    new Column().header("TOTAL").with(r -> r.total),
+                    new Column().header("FAILED").with(r -> r.failed),
+                    new Column().header("INFLIGHT").with(r -> r.inflight),
+                    new Column().header("LAST AGO").with(r -> r.sinceLast))));
         }
 
         return 0;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
index 3ca0bd3592f..3359cc518f6 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
@@ -30,6 +30,7 @@ import com.github.freva.asciitable.HorizontalAlign;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.json.JsonArray;
 import org.apache.camel.util.json.JsonObject;
 import org.apache.camel.util.json.Jsoner;
@@ -130,25 +131,24 @@ public class CamelRouteStatus extends ProcessBaseCommand {
         rows.sort(this::sortRow);
 
         if (!rows.isEmpty()) {
-            System.out.println(AsciiTable.getTable(AsciiTable.BASIC_ASCII_NO_DATA_SEPARATORS, rows, Arrays.asList(
-                    new Column().header("PID").with(r -> r.pid),
-                    new Column().header("Name").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
+            System.out.println(AsciiTable.getTable(AsciiTable.NO_BORDERS, rows, Arrays.asList(
+                    new Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
+                    new Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
                             .with(r -> maxWidth(r.name, 28)),
-                    new Column().header("Route ID").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
+                    new Column().header("ID").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(30)
                             .with(r -> maxWidth(r.routeId, 28)),
-                    new Column().header("From").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(40)
+                    new Column().header("FROM").dataAlign(HorizontalAlign.LEFT).maxColumnWidth(40)
                             .with(r -> maxWidth(r.from, 38)),
-                    new Column().header("State").with(r -> r.state),
-                    new Column().header("Age").with(r -> r.uptime),
-                    new Column().header("Total").headerAlign(HorizontalAlign.CENTER).with(r -> r.total),
-                    new Column().header("Failed").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(8).with(r -> r.failed),
-                    new Column().header("Inflight").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(10)
-                            .with(r -> r.inflight),
-                    new Column().header("Mean").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(8).with(r -> r.mean),
-                    new Column().header("Max").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(8).with(r -> r.max),
-                    new Column().header("Min").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(8).with(r -> r.min),
-                    new Column().header("Last Ago").headerAlign(HorizontalAlign.CENTER).maxColumnWidth(10)
-                            .with(r -> r.sinceLast))));
+                    new Column().header("STATE").headerAlign(HorizontalAlign.CENTER)
+                            .with(r -> StringHelper.capitalize(r.state)),
+                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.uptime),
+                    new Column().header("TOTAL").with(r -> r.total),
+                    new Column().header("FAILED").with(r -> r.failed),
+                    new Column().header("INFLIGHT").with(r -> r.inflight),
+                    new Column().header("MEAN").with(r -> r.mean),
+                    new Column().header("MIN").with(r -> r.min),
+                    new Column().header("MAX").with(r -> r.max),
+                    new Column().header("LAST AGO").with(r -> r.sinceLast))));
         }
 
         return 0;


[camel] 02/02: CAMEL-18406: camel-jbang - Status command

Posted by da...@apache.org.
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

commit 4401dad9d808e400564586f01d4818aa99b83fb9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Aug 24 16:41:08 2022 +0200

    CAMEL-18406: camel-jbang - Status command
---
 .../core/commands/process/ProcessBaseCommand.java  | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
index 519de022c41..727dbfe3ca5 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
@@ -17,7 +17,11 @@
 package org.apache.camel.dsl.jbang.core.commands.process;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.StringJoiner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
@@ -27,6 +31,9 @@ import org.apache.camel.util.StringHelper;
 
 abstract class ProcessBaseCommand extends CamelCommand {
 
+    private static final String[] DSL_EXT = new String[] { "groovy", "java", "js", "jsh", "kts", "xml", "yaml" };
+    private static final Pattern PATTERN = Pattern.compile("([\\w|\\-.])+");
+
     public ProcessBaseCommand(CamelJBangMain main) {
         super(main);
     }
@@ -63,10 +70,20 @@ abstract class ProcessBaseCommand extends CamelCommand {
         String name = StringHelper.after(cl, "main.CamelJBang run");
         if (name != null) {
             name = name.trim();
-        } else {
-            name = "";
+            StringJoiner js = new StringJoiner(" ");
+            // focus only on the route files supported (to skip such as readme files)
+            Matcher matcher = PATTERN.matcher(name);
+            while (matcher.find()) {
+                String part = matcher.group();
+                String ext = FileUtil.onlyExt(part, true);
+                if (ext != null && Arrays.asList(DSL_EXT).contains(ext)) {
+                    js.add(part);
+                }
+            }
+            return js.toString();
         }
-        return name;
+
+        return "";
     }
 
     static long extractSince(ProcessHandle ph) {