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:

  1. Apache commons CLI here...

    http://commons.apache.org/cli

    ReplyDelete
  2. 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.

    ReplyDelete
  3. CLI-parser (annotations based):

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

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

    ReplyDelete
  4. 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".

    ReplyDelete
  5. 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.

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

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

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

    ReplyDelete
  9. 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

    ReplyDelete
  10. 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

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

    ReplyDelete
  12. 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

    ReplyDelete
  13. 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

    ReplyDelete