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

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


The following commit(s) were added to refs/heads/it by this push:
     new 2473ee4a88f3 CAMEL-22703: camel-jbang - history to have it mode to 
show message data like debugger
2473ee4a88f3 is described below

commit 2473ee4a88f327751f7a3cc0765762d749e06f91
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Dec 7 22:24:25 2025 +0100

    CAMEL-22703: camel-jbang - history to have it mode to show message data 
like debugger
---
 .../core/commands/action/CamelHistoryAction.java   | 37 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
index 4bc611e14f3c..15374abe563b 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
@@ -210,9 +210,18 @@ public class CamelHistoryAction extends ActionWatchCommand 
{
                 line = line.trim();
                 if ("q".equalsIgnoreCase(line) || 
"quit".equalsIgnoreCase(line) || "exit".equalsIgnoreCase(line)) {
                     quit.set(true);
+                } else if ("p".equalsIgnoreCase(line)) {
+                    if (index.get() > 0) {
+                        index.decrementAndGet();
+                    }
+                } else if (line.isBlank() || "n".equalsIgnoreCase(line)) {
+                    index.incrementAndGet();
+                } else {
+                    int idx = lineIsNumber(line);
+                    if (idx >= 0) {
+                        index.set(idx);
+                    }
                 }
-                // user have pressed ENTER so continue
-                index.incrementAndGet();
                 waitForUser.set(false);
             }
         } while (!quit.get());
@@ -241,13 +250,35 @@ public class CamelHistoryAction extends 
ActionWatchCommand {
                 String s = String.format("Message History of last completed 
(id:%s status:%s ago:%s pid:%d name:%s)",
                         first.exchangeId, status, ago, first.pid, first.name);
                 printer().println(s);
+                printer().println();
 
                 int i = index.get();
+                if (i > rows.size()) {
+                    i = 0; // start over again
+                    index.set(0);
+                }
                 if (i < rows.size()) {
                     Row r = rows.get(i);
                     printSourceAndHistory(r);
                     printCurrentRow(r);
                 }
+                printer().println();
+
+                int total = rows.size() - 1;
+                int pos = i;
+
+                if (pos == total) {
+                    index.set(-1); // start over again
+                }
+
+                String msg
+                        = "    Message History (" + pos + "/" + total
+                          + "). Press ENTER to continue (n = next (default), p 
= previous, number = jump to index, q = quit).";
+                if (loggingColor) {
+                    
AnsiConsole.out().println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a(msg).reset());
+                } else {
+                    printer().println(msg);
+                }
                 waitForUser.set(true);
             }
         } while (!quit.get() || waitForUser.get());
@@ -259,7 +290,7 @@ public class CamelHistoryAction extends ActionWatchCommand {
         try {
             return Integer.parseInt(line);
         } catch (Exception e) {
-            return 0;
+            return -1;
         }
     }
 

Reply via email to