picocli

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/

How do I parse command line arguments in Java?

回眸只為那壹抹淺笑 提交于 2019-11-25 23:58:04
问题 What is a good way of parsing command line arguments in Java? 回答1: Check these out: http://commons.apache.org/cli/ http://www.martiansoftware.com/jsap/ Or roll your own: http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html For instance, this is how you use commons-cli to parse 2 string arguments: import org.apache.commons.cli.*; public class Main { public static void main(String[] args) throws Exception { Options options = new Options(); Option input = new Option("i", "input", true