The best CLI parser for Java [duplicate]

我怕爱的太早我们不能终老 提交于 2019-11-26 13:02:21

问题


This question already has an answer here:

  • How do I parse command line arguments in Java? 21 answers

What CLI parser for Java is easy to use and more scalable than others?


回答1:


Here are some of the most popular. They are all pretty feature complete, and having used the top two I can recommend them.

  • Commons CLI
    http://commons.apache.org/cli/

  • Java Gems
    http://code.google.com/p/javagems/

  • picocli (with colorized usage help and autocomplete)
    http://picocli.info/

  • JArgs
    http://jargs.sourceforge.net/

  • GetOpt
    http://www.urbanophile.com/arenn/hacking/download.html

EDIT: For completeness, here are some others I've come across

  • JOpt Simple
    http://jopt-simple.sourceforge.net/

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

  • ArgParser
    http://people.cs.ubc.ca/~lloyd/java/argparser.html

  • Natural CLI
    http://naturalcli.sourceforge.net/

  • TE-Code
    http://te-code.sourceforge.net/

  • JSAP
    http://www.martiansoftware.com/jsap/

  • CLAJR
    http://clajr.sourceforge.net/

  • CmdLn
    http://ostermiller.org/utils/CmdLn.html

  • JewelCli
    http://jewelcli.sourceforge.net/

  • JCommando
    http://jcommando.sourceforge.net/

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




回答2:


JLine is a library for building shell-like applications in Java.

  • Groovy is using it for it's shell implementation : groovysh.
  • JLine is also used by OpenTelegard/2 (JRuby).

Since 2002, the project was hosted on SourceForge.net and last release was JLine-1.0 on April 2011.

But in 2009, the project has started the migration to GitHub.com and has released the series 2.x since November 2009 (version 2.0). Last version 2.x when writing this answer is 2.14.2 in May 2016.

In October 2016, a new series 3.x has been released.




回答3:


I don't think scalability is a factor here. you want something which is feature complete and easy to use. I mostly use jargs but I generally dislike it's API (using it out of habit).

you can also try java getopt impl, which I did not personally used.



来源:https://stackoverflow.com/questions/1524661/the-best-cli-parser-for-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!