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.

18 comments:

yarin benado said...

Apache commons CLI here...

http://commons.apache.org/cli

Chris Winters 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.

Sam 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.

Eric Burke 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.

? 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

Earwin said...

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

DieLaughing 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

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa page and other update like as Beratnya Mengembalikan Jati Diri Bangsa, Mengembalikan Jati Diri Bangsa di perpanjang and Jangan Berhenti Mengembalikan Jati Diri Bangsa. Thank you So much.

Oes Tsetnoc | Lanjutkan Mengembalikan Jati Diri Bangsa

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa page and other update like as Beratnya Mengembalikan Jati Diri Bangsa, Mengembalikan Jati Diri Bangsa di perpanjang and Jangan Berhenti Mengembalikan Jati Diri Bangsa. Thank you So much.

Oes Tsetnoc | Lanjutkan Mengembalikan Jati Diri Bangsa

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

dainfo said...

workout at home with dumbbells
at home workouts
lose weight at home
abs workout at home
exercise machines at a gym
chest workout at home
get fit with exercise
how to exercise at home
run a marathon to shed pounds and improve cardio
how to lose weight at home
a healthy heart comes with exercise
medicine ball abs
fatigue your muscles by using weights or your body
upper body workout at home
be sure to hydrate your muscles as often as possible
dandruff home remedy
Good share you have here hope you keep it up, and don't forget to use dumbbells while exercising, even better though you can do these lose weight at home
where to buy venapro
buy venapro
venapro
venapro reviews
venapro review
best tooth whitening system
bleaching your teeth
teeth bleaching products
teeth bleaching trays
tooth whitening bleach