Java 命令行解析器 JOpt Simple
jopen
13年前
<p>JOpt Simple 是一个简单的、测试驱动的命令行解析器,支持 POSIX getopt() 和 GNU getopt_long()</p> <p>示例代码:</p> <pre class="brush:java; toolbar: true; auto-links: false;">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( "." ) ); } }</pre> <p></p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324995239061" target="_blank">http://www.open-open.com/lib/view/home/1324995239061</a></p>