JOpt Simple 4.6 发布,Java命令行解析器

jopen 11年前

JOpt Simple是一个简单,Java命令行解析器,用于那些你可能会传递给javac的的调用。它支持POSIX getopt() 和 GNU getopt_long()。
以下是一些用到JOpt Simple的项目:

  • OpenJDK. From Mark Reinhold: "I thought you might be interested to know that we're using your jopt-simple library in the open-source Java Development Kit. Thanks for writing such a nice little library! It's far cleaner than any of the other alternatives out there."
  • Gradle
  • NATBraille
  • Minecraft

package joptsimple.examples;    import joptsimple.OptionParser;  import joptsimple.OptionSet;  import org.junit.Test;    import static org.junit.Assert.*;    public class ShortOptionsTest {      @Test      public void supportsShortOptions() {          OptionParser parser = new OptionParser( "aB?*." );            OptionSet options = parser.parse( "-a", "-B", "-?" );            assertTrue( options.has( "a" ) );          assertTrue( options.has( "B" ) );          assertTrue( options.has( "?" ) );          assertFalse( options.has( "." ) );      }  }