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 c2ab2c09f91b56bd572de8ca2dd2ec5d30041e28
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Sep 25 11:07:40 2022 +0200

    camel-jbang - get endpoint filter negate
---
 .../core/commands/process/CamelEndpointStatus.java | 36 +++++++++++++++++++---
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelEndpointStatus.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelEndpointStatus.java
index 413b8133814..f45f77dee25 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelEndpointStatus.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelEndpointStatus.java
@@ -58,6 +58,10 @@ public class CamelEndpointStatus extends ProcessBaseCommand {
                         description = "Filter endpoints that must be higher 
than the given usage")
     long filterTotal;
 
+    @CommandLine.Option(names = { "--short-uri" },
+                        description = "List endpoint URI without query 
parameters (short)")
+    boolean shortUri;
+
     public CamelEndpointStatus(CamelJBangMain main) {
         super(main);
     }
@@ -101,8 +105,19 @@ public class CamelEndpointStatus extends 
ProcessBaseCommand {
                                 if (filterDirection != null && 
!filterDirection.equals(row.direction)) {
                                     add = false;
                                 }
-                                if (filter != null && 
!PatternHelper.matchPattern(row.endpoint, filter)) {
-                                    add = false;
+                                if (filter != null) {
+                                    String f = filter;
+                                    boolean negate = filter.startsWith("-");
+                                    if (negate) {
+                                        f = f.substring(1);
+                                    }
+                                    boolean match = 
PatternHelper.matchPattern(row.endpoint, f);
+                                    if (negate) {
+                                        match = !match;
+                                    }
+                                    if (!match) {
+                                        add = false;
+                                    }
                                 }
                                 if (limit > 0 && rows.size() >= limit) {
                                     add = false;
@@ -132,9 +147,20 @@ public class CamelEndpointStatus extends 
ProcessBaseCommand {
                         .with(r -> r.name),
                 new 
Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.age),
                 new Column().header("DIR").with(r -> r.direction),
-                new 
Column().header("URI").dataAlign(HorizontalAlign.LEFT).maxWidth(40, 
OverflowBehaviour.ELLIPSIS_RIGHT)
-                        .with(r -> r.endpoint),
-                new Column().header("TOTAL").with(r -> r.total))));
+                new Column().header("TOTAL").with(r -> r.total),
+                new 
Column().header("URI").dataAlign(HorizontalAlign.LEFT).maxWidth(90, 
OverflowBehaviour.ELLIPSIS_RIGHT)
+                        .with(this::getUri))));
+    }
+
+    private String getUri(Row r) {
+        String u = r.endpoint;
+        if (shortUri) {
+            int pos = u.indexOf('?');
+            if (pos > 0) {
+                u = u.substring(0, pos);
+            }
+        }
+        return u;
     }
 
     protected int sortRow(Row o1, Row o2) {

Reply via email to