最好的 Java CLI 解析器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1524661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The best CLI parser for Java
提问by Max
What CLI parser for Java is easy to use and more scalable than others?
哪种 Java 的 CLI 解析器易于使用且比其他解析器更具可扩展性?
采纳答案by user86614
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/GetOpt
http://www.urbanophile.com/arenn/hacking/download.html
Commons CLI
http://commons.apache.org/cli/picocli(带有彩色使用帮助和自动完成功能)
http://picocli.info/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/Natural CLI
http://naturalcli.sourceforge.net/JewelCli
http://jewelcli.sourceforge.net/JCommando
http://jcommando.sourceforge.net/Parse-cmd
http://code.google.com/p/parse-cmd/
Args4J
https://args4j.dev.java.net/ArgParser
http://people.cs.ubc.ca/~lloyd/java/argparser.htmlJewelCli
http://jewelcli.sourceforge.net/JCommando
http://jcommando.sourceforge.net/
回答by Omry Yadan
I don't think scalability is a factor here. you want something which is feature complete and easy to use. I mostly use jargsbut I generally dislike it's API (using it out of habit).
我不认为可扩展性是这里的一个因素。您想要功能完整且易于使用的东西。我主要使用jargs,但我通常不喜欢它的 API(出于习惯使用它)。
you can also try java getoptimpl, which I did not personally used.
你也可以试试java getoptimpl,我个人没有用过。
回答by Gregory Mostizky
JLineis a library for building shell-like applications in Java.
JLine是一个用于在 Java 中构建类 shell 应用程序的库。
- Groovy is using it for it's shell implementation :
groovysh
. - JLine is also used by OpenTelegard/2(JRuby).
- Groovy是使用它的它的壳实现:
groovysh
。 - JLine 也被OpenTelegard/2(JRuby) 使用。
Since 2002, the project was hosted on SourceForge.netand last release was JLine-1.0on April 2011.
自 2002 年以来,该项目托管在SourceForge.net 上,最后一次发布是2011 年 4 月的JLine-1.0。
But in 2009, the project has started the migration to GitHub.comand has released the series 2.xsince November 2009 (version 2.0). Last version 2.x when writing this answer is 2.14.2 in May 2016.
但在 2009 年,该项目已经开始迁移到 GitHub.com,并从 2009 年 11 月开始发布 2.x 系列(2.0 版)。撰写此答案时的最新版本 2.x 是 2016 年 5 月的 2.14.2。
In October 2016, a new series 3.x has been released.
在2016年10月,一名新系列3.X已被释放。