This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch kamelet-debug in repository https://gitbox.apache.org/repos/asf/camel.git
commit bc5a4805beb752fdff3e06fdea1c2e97678d6f67 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Nov 15 12:32:50 2023 +0100 camel-jbang - Debug command to show source in history with line number --- .../java/org/apache/camel/impl/console/DebugDevConsole.java | 7 ++++++- .../java/org/apache/camel/dsl/jbang/core/commands/Debug.java | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java index 0604f121a3e..6f6540ce673 100644 --- a/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java +++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java @@ -237,7 +237,12 @@ public class DebugDevConsole extends AbstractDevConsole { if (h.getNode() != null) { jo.put("nodeId", h.getNode().getId()); if (h.getNode().getLocation() != null) { - jo.put("location", h.getNode().getLocation()); + String loc = h.getNode().getLocation(); + // strip schema + if (loc.contains(":")) { + loc = StringHelper.after(loc, ":"); + } + jo.put("location", loc); } if (h.getNode().getLineNumber() != -1) { jo.put("line", h.getNode().getLineNumber()); diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java index f5d788235e9..64b4afbe186 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java @@ -515,7 +515,7 @@ public class Debug extends Run { String ids; if (source) { - ids = h.location; + ids = locationAndLine(h.location, h.line); } else { ids = h.routeId + "/" + h.nodeId; } @@ -604,7 +604,7 @@ public class Debug extends Run { // node ids or source location String ids; if (source) { - ids = row.location; + ids = locationAndLine(row.location, -1); } else { ids = row.routeId + "/" + getId(row); } @@ -642,6 +642,12 @@ public class Debug extends Run { System.out.println(); } + private static String locationAndLine(String loc, int line) { + // shorten path as there is no much space + loc = FileUtil.stripPath(loc); + return line == -1 ? loc : loc + ":" + line; + } + private void clearScreen() { AnsiConsole.out().print(Ansi.ansi().eraseScreen().cursor(1, 1)); }
