jcommander
jcommander copied to clipboard
Support no value on dynamic parameters
I would like to support something like:
java Main -Da=b -De -Dc=d
Here the second argument doesn't provide a value. This is a common practice with Maven plugins (for example -DskipTests).
Would it be possible to enhance @DynamicParameter to support this syntax. I would expect that the Map will contains an entry with key="e" and value=null.
+1
@cbeust still an issue
public void dynamic() {
class Args {
@DynamicParameter(names = "-D", description = "Dynamic parameters go here")
private Map<String, String> params = new HashMap<>();
}
JCommander jc = new JCommander();
Args args = new Args();
jc.addObject(args);
jc.parse("-Da=b","-De","-Dc=d");
Assert.assertEquals(3, args.params.size());
}
Worth implementing?
Yes. that's a reasonable request.
+1 for this. Any idea on when this will be available?