apache-comnons系列之commons-cli1.4 学习笔记

58 篇文章 0 订阅
53 篇文章 1 订阅

apache-comnons系列之commons-cli1.4 学习笔记

概述

  • 参考
  • CommandLineParser
    • A class that implements the CommandLineParser interface can parse a String array according to the {@link Options} specified and return a {@link CommandLine}.
  • DefaultParser
    • Default parser.
  • Option
    • Describes a single command-line option. It maintains information regarding the short-name of the option, the long-name,
      if any exists, a flag indicating if an argument is required for this option, and a self-documenting description of the option.
  • Options
    • Options represents a collection of {@link Option} objects, which describe the possible options for a command-line.
  • OptionGroup
    • A group of mutually exclusive options.
    • optionMap = new LinkedHashMap

测试

  • org.apache.commons.cli.OptionTest
    • opt—-the name of the option
    • longOpt—-the long representation of the option
    • argName—-the name of the argument for this option
    • description/required
    • numberOfArgs
      • the number of argument values this option can have
    • valuesep
      • the character that is the value separator
    • List values = new ArrayList();—-the list of argument values
    • acceptsArg
      • Tells if the option can accept more arguments.
  • org.apache.commons.cli.OptionsTest
    • shortOpts/longOpts/requiredOpts/optionGroups
  • org.apache.commons.cli.CommandLineTest
    • args = new LinkedList();/options = new ArrayList();
    • args用于接收无法处理的参数
  • org.apache.commons.cli.DefaultParserTest
  • org.apache.commons.cli.ParserTestCase
    • Option currentOption—-The last option parsed.(表示期望解析参数的option)
    • parse流程
      • handleToken
      • currentOption.addValueForProcessing
        • processValue
        • add(value);
    • handleUnknownToken
      • cmd.addArg(token);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值