zoukankan      html  css  js  c++  java
  • JOpt Simple 4.5 发布,命令行解析器

    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 }
  • 相关阅读:
    对于“口袋精灵”单元测试
    12-17:项目进度
    12-15:项目进度
    12-14:项目进度
    12-13:项目进度
    12-12:项目进度
    12-11:项目进度
    12-10:项目进度
    12-9:项目进度
    12-6:项目进度
  • 原文地址:https://www.cnblogs.com/shihao/p/3113708.html
Copyright © 2011-2022 走看看