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 }
  • 相关阅读:
    WebService
    JavaMail
    ssh框架整合
    CSS3初步
    SpringMVC 文件上传及下载
    Java多线程
    SpringMVC 数据校验
    初始化参数绑定——日期格式
    SpringMVC入门
    Quartz
  • 原文地址:https://www.cnblogs.com/shihao/p/3113708.html
Copyright © 2011-2022 走看看