java commons cli_在指定附加值时Java Apache Common CLI双精灵选项失败

仅供参考:我在Windows计算机上运行此Java程序。我相信这很重要。在指定附加值时Java Apache Common CLI双精灵选项失败

基本上,我有一个问题,指定一个值到双连字符的选项。单连字选项正常工作。

import org.apache.commons.cli.*;

public class Test {

public static void main(String[] args) throws ParseException {

String[] arguments = new String[] { "--input file.txt" };

// create the Options

Options options = new Options();

options.addOption("i", "input", false, "Specify the input file.");

// Create the parser

CommandLineParser parser = new GnuParser();

// Parse the command line

CommandLine cmd = parser.parse(options, arguments);

}

}

程序失败,错误:

Exception in thread "main" org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: --input file.txt

如果我指定的参数作为-i file.txt,没有错误。如果参数是--input,也没有错误。为什么双连字符选项不接受任何值?它与解析器有关,还是我在Windows机器上运行它?

我在这里做错了什么?任何帮助,将不胜感激。

非常感谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值