添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I wanted to try out the Apache Commons CLI, and figured a good place to start would be the 'usage' section on its web page.

http://commons.apache.org/proper/commons-cli/usage.html

Now, the example suggest to create a DefaultParser , however the closest sounding I could find is BasicParser . Is this the thing to use, am I missing something?

I used GnuParser() instead of DefaultParser() and it works well.
CommandLineParser parser = new GnuParser();
Update : In version 1.3.1 of CLI, GnuParser() is now deprecated. So I simply added

import org.apache.commons.cli.DefaultParser;

and now I use CommandLineParser parser = new DefaultParser();

And all is fine!

I've encountered the same problem while following same usage guide with commons-cli 1.2 and found the following available parsers:

  • org.apache.commons.cli.BasicParser
  • org.apache.commons.cli.GnuParser
  • org.apache.commons.cli.PosixParser
  • They all extends the org.apache.commons.cli.Parser and only implement the flatten method. You can check Parser's javadoc (and implementing parsers) for more information.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .