jcommander
jcommander copied to clipboard
List parameter overwrite not as expected
Hello,
Thank you for your awesome library! It fits almost perfect all the use cases that I need, but unfortunately I came across a small inconsistency that I cannot work around.
I am not sure if this is intended behavior or not, but the issue is that I cannot overwrite list parameters. What happens instead is that the values that should overwrite are instead appended to the list.
For example "-bars", "b1,b2,b3", "-bars", "b4"
would result in the list containing [b1, b2, b3, b4]
instead of the expected b4
.
I created a small junit test for this case in the following repo link.
Is this intended behaviour? Can you please provide feedback if this needs to be fixed?
Best regards, Cristian
The behavior seems to be in line with the documentation: http://jcommander.org/#_lists
@zentol On the flip side, that does not mention the case where allowParameterOverwriting is set to true. In fact, there's not a single mention of allowParameterOverwriting
in the docs...
@cristiantoader It seems to me that allowParameterOverwriting
parameter is a bit of an afterthought and doesn't really play well with other things for that reason. For example, forceNonOverwritable struck me as a bit strange: using force
and non
together in a variable name just begs for the question whether it should be designed somewhat differently. As is always the case, it probably seemed like the best idea at the time :)
I guess the solution for now is to take in a String
and split it manually...