Claus Ibsen created CAMEL-25437:
-----------------------------------
Summary: camel-jbang - camel run --prop key=value with a space is
silently ignored
Key: CAMEL-25437
URL: https://issues.apache.org/jira/browse/CAMEL-25437
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
camel run --prop key=value, with a space between the option and its value, is
silently ignored: the property is not set, and nothing warns. Only the attached
form --prop=key=value works.
Reproduce in a folder with a route that logs {{greeting}} and an
application.properties with greeting=Hello:
{noformat}
camel run route.camel.yaml --prop greeting=FromProp
-> logs "Hello" (application.properties wins, the --prop is lost)
camel run route.camel.yaml --prop=greeting=FromProp
-> logs "FromProp", and the startup summary lists it as [Command Line]
greeting = FromProp
{noformat}
Cause: the option is declared with arity = "0" (Run.java, and the same option
in Script.java, since CAMEL-17968):
{noformat}
@Option(names = { "--prop", "--property" }, description = "Additional
properties (override existing)", arity = "0")
public String[] property;
{noformat}
With arity 0, picocli takes no separate value for the option and accepts only
the attached --prop=value form. The separate key=value then goes on as a
positional argument, a file to run, which is not found and dropped without a
word. So it is the declaration in camel-jbang rather than a picocli bug.
The space form is the one people (and AI agents) type first, as for every other
option, and the run looks fine apart from the wrong value, so it is hard to
find.
Proposal: drop arity = "0" so --prop takes one value per occurrence, as --dep
does (repeating --prop for several properties keeps working, and
--prop=key=value too). Alternatively, warn when a positional argument looks
like key=value and is not a file.
Found on 4.23.0-SNAPSHOT.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)