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

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


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new 4d0578ee450b [4.18.x] CAMEL-25437: camel-jbang - --prop takes its 
value after a space too (#27541)
4d0578ee450b is described below

commit 4d0578ee450baa65d903ecdf7ad061103e34a250
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 8 09:59:36 2026 +0200

    [4.18.x] CAMEL-25437: camel-jbang - --prop takes its value after a space 
too (#27541)
    
    * CAMEL-25437: camel-jbang - --prop takes its value after a space too
    
    --prop was declared with arity 0, so picocli took no separate value for
    it: camel run --prop key=value lost the property, as key=value went on
    as a file to run, and nothing warned. Only --prop=key=value worked.
    --prop now takes one value, after a space or an equals sign, on camel
    run and camel script.
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
    (cherry picked from commit 8f681514cca5d1bb94acf6439dee2426364e0825)
    
    * CAMEL-25437: camel-jbang - --prop of camel cmd send and receive takes its 
value after a space too
    
    Review follow-up: camel cmd send and camel cmd receive had the same
    arity 0 on --prop, so a value after a space went to the name of the
    integration.
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
    (cherry picked from commit 68399a6c8bf2bd5e21a6d22be82ecdc1ff1fa667)
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  |  2 +-
 .../camel/dsl/jbang/core/commands/Script.java      |  3 +-
 .../core/commands/action/CamelReceiveAction.java   |  3 +-
 .../core/commands/action/CamelSendAction.java      |  3 +-
 .../dsl/jbang/core/commands/RunPropOptionTest.java | 56 ++++++++++++++++++++++
 .../commands/action/CamelActionPropOptionTest.java | 47 ++++++++++++++++++
 6 files changed, 107 insertions(+), 7 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index e73106614c6b..1e0a28ef5f38 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -299,7 +299,7 @@ public class Run extends CamelCommand {
                           " (ex. 
/path/to/file.properties,/path/to/other.properties")
     public String propertiesFiles;
 
-    @Option(names = { "--prop", "--property" }, description = "Additional 
properties (override existing)", arity = "0")
+    @Option(names = { "--prop", "--property" }, description = "Additional 
properties (override existing)")
     public String[] property;
 
     @Option(names = { "--stub" }, description = "Stubs all the matching 
endpoint uri with the given component name or pattern."
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Script.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Script.java
index 13244960fb55..19eec917291b 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Script.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Script.java
@@ -54,8 +54,7 @@ public class Script extends CamelCommand {
                         description = "Load properties file for route 
placeholders (ex. /path/to/file.properties")
     String propertiesFiles;
 
-    @CommandLine.Option(names = { "--prop", "--property" }, description = 
"Additional properties (override existing)",
-                        arity = "0")
+    @CommandLine.Option(names = { "--prop", "--property" }, description = 
"Additional properties (override existing)")
     String[] property;
 
     public Script(CamelJBangMain main) {
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelReceiveAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelReceiveAction.java
index c9c8cd9d297f..b2012795bc58 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelReceiveAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelReceiveAction.java
@@ -105,8 +105,7 @@ public class CamelReceiveAction extends ActionBaseCommand {
     String propertiesFiles;
 
     @CommandLine.Option(names = { "--prop", "--property" },
-                        description = "Additional properties; override 
existing (only applicable when NOT using an existing running Camel)",
-                        arity = "0")
+                        description = "Additional properties; override 
existing (only applicable when NOT using an existing running Camel)")
     String[] property;
 
     @CommandLine.Option(names = { "--action" }, completionCandidates = 
ActionCompletionCandidates.class,
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
index 747b8a6be403..1851edce5618 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
@@ -65,8 +65,7 @@ public class CamelSendAction extends ActionBaseCommand {
     String propertiesFiles;
 
     @CommandLine.Option(names = { "--prop", "--property" },
-                        description = "Additional properties; override 
existing (only applicable when NOT using an existing running Camel)",
-                        arity = "0")
+                        description = "Additional properties; override 
existing (only applicable when NOT using an existing running Camel)")
     String[] property;
 
     @CommandLine.Option(names = { "--endpoint", "--uri" },
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunPropOptionTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunPropOptionTest.java
new file mode 100644
index 000000000000..a2e4ff76fe99
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunPropOptionTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * CAMEL-25437: --prop takes its value after a space too, as every other 
option does, instead of losing it to the files
+ * to run.
+ */
+class RunPropOptionTest {
+
+    @Test
+    void aPropertyAfterASpace() {
+        Run run = new Run(new CamelJBangMain());
+        new CommandLine(run).parseArgs("route.camel.yaml", "--prop", 
"greeting=Hi");
+
+        assertThat(run.property).containsExactly("greeting=Hi");
+        assertThat(run.files).containsExactly("route.camel.yaml");
+    }
+
+    @Test
+    void propertiesInEveryForm() {
+        Run run = new Run(new CamelJBangMain());
+        new CommandLine(run).parseArgs("--prop=a=1", "--prop", "b=2", 
"--property", "c=3", "route.camel.yaml");
+
+        assertThat(run.property).containsExactly("a=1", "b=2", "c=3");
+        assertThat(run.files).containsExactly("route.camel.yaml");
+    }
+
+    @Test
+    void aScriptPropertyAfterASpace() {
+        Script script = new Script(new CamelJBangMain());
+        new CommandLine(script).parseArgs("--prop", "greeting=Hi", 
"route.camel.yaml");
+
+        assertThat(script.property).containsExactly("greeting=Hi");
+        assertThat(script.file).isEqualTo("route.camel.yaml");
+    }
+}
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelActionPropOptionTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelActionPropOptionTest.java
new file mode 100644
index 000000000000..bf2e387edb0b
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelActionPropOptionTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.action;
+
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * CAMEL-25437: --prop of camel cmd send and receive takes its value after a 
space too, instead of losing it to the name
+ * of the integration.
+ */
+class CamelActionPropOptionTest {
+
+    @Test
+    void sendTakesAPropertyAfterASpace() {
+        CamelSendAction send = new CamelSendAction(new CamelJBangMain());
+        new CommandLine(send).parseArgs("--prop", "greeting=Hi", 
"--prop=other=1");
+
+        assertThat(send.property).containsExactly("greeting=Hi", "other=1");
+        assertThat(send.name).isNull();
+    }
+
+    @Test
+    void receiveTakesAPropertyAfterASpace() {
+        CamelReceiveAction receive = new CamelReceiveAction(new 
CamelJBangMain());
+        new CommandLine(receive).parseArgs("--prop", "greeting=Hi");
+
+        assertThat(receive.property).containsExactly("greeting=Hi");
+    }
+}

Reply via email to