They say that a Java framework is not complete until it provides factories, and since it’s something that JCommander was still lacking, it had to be fixed.
Introducing JCommander 1.4.
Here is what’s new:
- You can now specify default values in a more flexible way than at field declaration time (documentation).
- You can use string converter factories instead of specifying converter classes on each @Parameter annotation (documentation).
- The usage is now prettier:
Usage: <main class> [options] Options: -debug Debug mode (default: false) -groups Comma-separated list of group names to be run * -log, -verbose Level of verbosity (default: 1) -long A long number (default: 0)
- Many bug fixes and a more clever option parsing to cover odd cases.
- This release actually contains more features but I’m not telling.
All the goodness available at the usual place. Operators are standing by, order now!
#1 by Dmitri on July 31, 2010 - 4:57 pm
Thanks! That was a really quick turn-around time on the new features.
#2 by Duncan McGregor on August 5, 2010 - 4:48 am
Very nice, thank you.
One question – can I replace in the usage, or get the message as a string to replace it myself?
Cheers
#3 by Duncan McGregor on August 5, 2010 - 4:49 am
Oh, stupid comment sanitizers! Let’s try
can I replace >main class< in the usage
#4 by Duncan McGregor on August 5, 2010 - 4:50 am
Ah well, you get the drift đŸ˜‰
#5 by Cedric on August 5, 2010 - 5:11 am
Hi Duncan,
Yes, in the upcoming version, you can call JCommander#setProgramName() (you can get it from github if you want to try it now).
#6 by Duncan McGregor on August 5, 2010 - 5:29 am
On reflection (no pun intended;-) it would be handy to get at the usage as a string. That way when my Swing app is invoked badly it can print the usage in a message box rather than to the console that isn’t there.
Maybe I’ll have a trawl through the source…
Cheers
Duncan
Pingback: JCommander: Gestor de Archivos Java y Utilidad Java para gestionar parĂ¡metros por lĂnea de comandos « Java Mania