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

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

commit f9328307cc19c6218988e06e4483ed1609894700
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue May 26 15:57:16 2026 +0200

    CAMEL-23617: CLI endpoint command - human-readable sizes and sort by size
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../dsl/jbang/core/commands/process/ListEndpoint.java   | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListEndpoint.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListEndpoint.java
index 433b9b15d5d5..85449071e587 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListEndpoint.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListEndpoint.java
@@ -47,7 +47,7 @@ public class ListEndpoint extends ProcessWatchCommand {
 
         @Override
         public Iterator<String> iterator() {
-            return List.of("pid", "name", "age", "total").iterator();
+            return List.of("pid", "name", "age", "total", "size").iterator();
         }
 
     }
@@ -56,7 +56,7 @@ public class ListEndpoint extends ProcessWatchCommand {
     String name = "*";
 
     @CommandLine.Option(names = { "--sort" }, completionCandidates = 
PidNameAgeTotalCompletionCandidates.class,
-                        description = "Sort by pid, name, age or total", 
defaultValue = "pid")
+                        description = "Sort by pid, name, age, total, or 
size", defaultValue = "pid")
     String sort;
 
     @CommandLine.Option(names = { "--limit" },
@@ -256,7 +256,16 @@ public class ListEndpoint extends ProcessWatchCommand {
     }
 
     private static String sizeToString(long size) {
-        return size >= 0 ? Long.toString(size) : "-";
+        if (size < 0) {
+            return "-";
+        }
+        if (size < 1024) {
+            return size + " B";
+        } else if (size < 1024 * 1024) {
+            return String.format("%.1f KB", size / 1024.0);
+        } else {
+            return String.format("%.1f MB", size / (1024.0 * 1024.0));
+        }
     }
 
     protected int sortRow(Row o1, Row o2) {
@@ -275,6 +284,8 @@ public class ListEndpoint extends ProcessWatchCommand {
                 return Long.compare(o1.uptime, o2.uptime) * negate;
             case "total":
                 return Long.compare(Long.parseLong(o1.total), 
Long.parseLong(o2.total)) * negate;
+            case "size":
+                return Long.compare(o1.meanBodySize, o2.meanBodySize) * negate;
             default:
                 return 0;
         }

Reply via email to