Open JosephWPlant opened 9 years ago
fix implemented in pull request https://github.com/kohsuke/args4j/pull/93#issuecomment-61959339 #93
I can't fix this without breaking backward compatibility, as this commit changes the default handling of a method with @Argument
.
The closest change I can think of is to only treat @Argument
as multi-valued when its index is the largest, but in your example it'll not prevent people from specifying 3 options when you only expected two.
I have a set of arguments in a specific order. Each needs validation applying to it, so parsing to a method instead of a variable is beneficial. So my code should look something like this:
Unfortunately, args4J currently presumes that arguments with a method are multivalued arguments, and thusly associates all arguments with the same method. For example, if there were 2 arguments
argument0 argument1
, both would be parsed with method0, when it should be possible to have each parsed with it's own relevant method.My fix has involved editing the method
isMultiValued()
inorg.kohsuke.args4j.spi.MethodSetter
to return false instead of true, stopping the parser from using this same method for all arguments, and instead moving onto the next argument/method indexIt would be nice to have this use the multiValued field of Argument (ie
@Argument(index = 0, multiValue = false)</code.