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 fc623c8881c camel-jbang - ps with only pid
fc623c8881c is described below

commit fc623c8881c4ea808d735fd9df4ad3626d372fbd
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Sep 23 11:19:39 2022 +0200

    camel-jbang - ps with only pid
---
 .../jbang/core/commands/process/ListProcess.java   | 25 +++++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
index c5346912b82..ee430899932 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
@@ -37,6 +37,10 @@ public class ListProcess extends ProcessBaseCommand {
                         description = "Sort by pid, name or age", defaultValue 
= "pid")
     String sort;
 
+    @CommandLine.Option(names = { "--pid" },
+                        description = "List only pid in the output")
+    boolean pid;
+
     public ListProcess(CamelJBangMain main) {
         super(main);
     }
@@ -76,14 +80,19 @@ public class ListProcess extends ProcessBaseCommand {
         rows.sort(this::sortRow);
 
         if (!rows.isEmpty()) {
-            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).maxWidth(40, 
OverflowBehaviour.ELLIPSIS_RIGHT)
-                            .with(r -> r.name),
-                    new 
Column().header("READY").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
-                    new 
Column().header("STATUS").headerAlign(HorizontalAlign.CENTER)
-                            .with(r -> extractState(r.state)),
-                    new 
Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.ago))));
+            if (pid) {
+                rows.forEach(r -> System.out.println(r.pid));
+            } else {
+                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)
+                                .maxWidth(40, OverflowBehaviour.ELLIPSIS_RIGHT)
+                                .with(r -> r.name),
+                        new 
Column().header("READY").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
+                        new 
Column().header("STATUS").headerAlign(HorizontalAlign.CENTER)
+                                .with(r -> extractState(r.state)),
+                        new 
Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.ago))));
+            }
         }
 
         return 0;

Reply via email to