This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.22.x by this push:
new 5d488cce1e54 [4.22.x] CAMEL-25437: camel-jbang - --prop takes its
value after a space too (#27540)
5d488cce1e54 is described below
commit 5d488cce1e54933c3d0993f2f1cd830261ada1be
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 8 09:27:07 2026 +0200
[4.22.x] CAMEL-25437: camel-jbang - --prop takes its value after a space
too (#27540)
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.
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
(cherry picked from commit 8f681514cca5d1bb94acf6439dee2426364e0825)
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 +-
.../dsl/jbang/core/commands/RunPropOptionTest.java | 56 ++++++++++++++++++++++
3 files changed, 58 insertions(+), 3 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 0cf49cf11e9f..d9a773a89a65 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 5d60efca98ba..9b1a6bae76cc 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
@@ -58,8 +58,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/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");
+ }
+}