Following TC should pass
@Test
public void arity() {
class Parameters {
@Parameter(names = {"--mv"}, arity = 2)
private List<MvParameters> mvParameters;
}
Parameters args = new Parameters();
JCommander.newBuilder()
.addObject(args)
.args(new String[]{"--mv", "from1", "to1", "--mv", "from2", "to2"})
.build();
Assert.assertNotNull(args.mvParameters);
Assert.assertEquals(args.mvParameters.size(), 2);
Assert.assertEquals(args.mvParameters.getFirst().from, "from1");
Assert.assertEquals(args.mvParameters.getFirst().to, "to1");
Assert.assertEquals(args.mvParameters.getLast().from, "from2");
Assert.assertEquals(args.mvParameters.getLast().to, "to2");
}
I want to run the command like below
./my_cmd --mv to1 from1 --mv to2 from2
I also saw a mention in the doc Also, note that only List<String> is allowed for parameters that define an arity. You will have to convert these values yourself if the parameters you need are of type Integer or other (this limitation is due to Java’s erasure). in 10.1. Fixed arities at doc. If same limitation applies here then this issue can be closed
Following TC should pass
I want to run the command like below
I also saw a mention in the doc
Also, note that only List<String> is allowed for parameters that define an arity. You will have to convert these values yourself if the parameters you need are of type Integer or other (this limitation is due to Java’s erasure).in10.1. Fixed aritiesat doc. If same limitation applies here then this issue can be closed