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 671d7a18485 CAMEL-18538: camel-jbang - Log command
671d7a18485 is described below

commit 671d7a18485496163aa9f62b80ca7bb632b6292b
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Jan 6 07:39:26 2023 +0100

    CAMEL-18538: camel-jbang - Log command
---
 .../dsl/jbang/core/commands/action/CamelLogAction.java     | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
index f350d0a1b16..5894eaa2375 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
@@ -62,8 +62,8 @@ public class CamelLogAction extends ActionBaseCommand {
     String since;
 
     @CommandLine.Option(names = { "--find" },
-                        description = "Find and highlight matching text 
(ignore case).")
-    String find;
+                        description = "Find and highlight matching text 
(ignore case).", arity = "0..*")
+    String[] find;
 
     String findAnsi;
 
@@ -110,7 +110,11 @@ public class CamelLogAction extends ActionBaseCommand {
             // read existing log files (skip by tail/since)
             if (find != null) {
                 findAnsi = 
Ansi.ansi().fg(Ansi.Color.BLACK).bg(Ansi.Color.YELLOW).a("$0").reset().toString();
-                find = Pattern.quote(find);
+                for (int i = 0; i < find.length; i++) {
+                    String f = find[i];
+                    f = Pattern.quote(f);
+                    find[i] = f;
+                }
             }
             Date limit = null;
             if (since != null) {
@@ -229,7 +233,9 @@ public class CamelLogAction extends ActionBaseCommand {
         if (find != null) {
             String before = StringHelper.before(line, "---");
             String after = StringHelper.after(line, "---");
-            after = after.replaceAll("(?i)" + find, findAnsi);
+            for (String f : find) {
+                after = after.replaceAll("(?i)" + f, findAnsi);
+            }
             line = before + "---" + after;
         }
         System.out.println(line);

Reply via email to