@Parameter(names= "-nofoo", description="do not use foo")
public boolean withFoo = true; // but false if the option is given
That’s a good idea, I just added support for this in 1.70, which is now available on JCenter:
@Test
public void invertedBoolean() {
class Args {
@Parameter(names = {"--f"})
private boolean f = true;
}
Args args = new Args();
JCommander.newBuilder()
.addObject(args)
.args(new String[] { "--f"})
.build();
Assert.assertEquals(args.f, false);
}
--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Cédric
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--Cédric
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.