JOpt Simple 4.5 包含一些小的增强,包括:

  • Resolved gh-17 by offering OptionParser.nonOptions() and NonOptionArgumentSpec.
  • Resolved gh-27 by offering OptionParser.allowsUnrecognizedOptions().

JOpt Simple 是一个简单的、测试驱动的命令行解析器,支持 POSIX getopt() 和 GNU getopt_long()

示例代码:

01 package joptsimple.examples;
02  
03 import joptsimple.OptionParser;
04 import joptsimple.OptionSet;
05 import org.junit.Test;
06 import static org.junit.Assert.*;
07  
08 public class ShortOptionsTest {
09     @Test
10     public void supportsShortOptions() {
11         OptionParser parser = new OptionParser( "aB?." );
12  
13         OptionSet options = parser.parse( "-a", "-B", "-?" );
14  
15         assertTrue( options.has( "a" ) );
16         assertTrue( options.has( "B" ) );
17         assertTrue( options.has( "?" ) );
18         assertFalse( options.has( "." ) );
19     }
20 }

相关文章:

  • 2022-01-10
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-11-15
  • 2021-09-11
猜你喜欢
  • 2021-04-27
  • 2021-09-14
  • 2021-11-10
  • 2021-06-14
  • 2021-04-16
相关资源
相似解决方案