Wednesday, July 9, 2008

I'm curious: what do you use to parse command-line options in your Java programs?

You know, -r, -w, -rwl, --use-flibbert, --foobar=12 and all that kinda stuff.

16 comments:

Yarin Benado said...

Apache commons CLI here...

http://commons.apache.org/cli

Unknown said...

Commons CLI here too; I don't remember there being a lot of choices the last time I looked, but that was some time ago. And I probably didn't spend a huge amount of time looking.

Unknown said...

CLI-parser (annotations based):

http://code.google.com/p/cli-parser/

It is < 10k and does a great, terse job.

Alex Miller said...

You should read this: http://javathink.blogspot.com/2008/04/why-does-parsing-arguments-in-java-suck.html.

Unknown said...

We tried Commons CLI on one project a few years ago, but at the time it seemed like a very odd, cumbersome API. Maybe that's changed, I don't know. For the few command line args I've had to parse, I just manually walk the array and hand-code it. For apps with a handful of args, this seems preferable to sucking in yet another "mini framework".

Sam said...

Eric:

Try out cli-parser.. it is tiny, has no dependencies and makes it much easier than your solution even for just a few arguments.

Tom said...

https://args4j.dev.java.net/

l0st3d said...

We've used JOpt Simple in a couple of small projects. I liked how easy it was to get things like help out of it's data structure, and how clear the construction of the options were in the code.

Arek Stryjski said...

JASP http://www.martiansoftware.com/jsap/

harryh said...

Something I needed that Apache Commons CLI didn't do:

myprogram --foo xxx --foo yyy

would somehow get me a List<String> with xxx and yyy in it.

I've now settled on args4j

J.F. Zarama said...

I found CLIs a bit too complex for my use on small prototype console applications.

I have created a project and uploaded the source using google-code.

I am a student of Java so I am sure a number of enhancements to this class are needed; fyi, have a look at:

http://code.google.com/p/parse-cmd/

btw: thanks to Bob and you for Guice; it is a real useful tool; simple and useful.

jf.zarama@gmail.com

Unknown said...

I second args4j, it's insanely simple to use.

J. Adam Moore said...

Yes, I do.

jlorenzen said...

I haven't had an opportunity yet to use it, but I have been keeping my eye on Groovy's CLIBuilder, which seems dead simple. Here is an example of it being used, http://docs.codehaus.org/display/GROOVY/WrappingGroovyScript

combattery84 said...

LG Laptop Battery
SAMSUNG Laptop Battery
SONY Laptop Battery
TOSHIBA Laptop Battery
APPLE M8403 battery
APPLE A1078 Battery
APPLE A1079 battery
APPLE A1175 battery
APPLE a1185 battery
APPLE A1189 battery 1
Acer aspire 5920 battery
Acer btp-arj1 battery
Acer LC.BTP01.013 battery
Acer ASPIRE 1300 battery
Acer ASPIRE 1310 battery
Acer Aspire 1410 battery
Acer ASPIRE 1680 battery
ACER BTP-63D1 battery
ACER BTP-43D1 battery
Acer lc.btp05.001 battery
Acer aspire 3000 battery
Acer Travelmate 4000 battery
ACER aspire 5560 battery
ACER BATBL50L6 battery
ACER TravelMate 240 Battery
ACER BT.00803.004 Battery
ACER Travelmate 4002lmi battery
Acer travelmate 800 battery
Acer aspire 3613wlmi battery
Travelmate 2414wlmi battery
Acer batcl50l battery
Acer Travelmate 2300 battery
ACER aspire 3610 battery
ACER travelmate 4600 battery
Dell Latitude D800 battery

Plumbing & HVAC Services San Diego said...

Compre documentos en línea, documentos originales y registrados.
Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

Comprar permiso de residencia,
permiso de residenciareal y falso en línea,
Compre licencia de conducir en línea,
Compre una licencia de conducir española falsa en línea,
Comprar tarjeta de identificación,
Licencia de conducir real y falsa,
Compre pasaporte real en línea,

Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
Address: 56 Guild Street, London, EC4A 3WU (UK)
Email: contact@permisodeespana.com
WhatsApp: +443455280186