我正在使用Common CLI作爲個人項目。我從文檔中找不到的一件事是,如何執行某個論點來呈現。Apache Common CLI:如何添加參數?
爲了澄清我的問題,我可以定義參數和選項之間的不同,命令:
mycommand file.txt -b 2
mycommand is the command,
file.txt is the argument
-b 2 is the option where 2 is the option value
共同CLI,我可以添加-B 2爲這樣一個選項:
options.addOption("b", true, "Some message");
並採用解析參數:
CommandLineParser commandParser = new GnuParser();
CommandLine result = commandParser.parse(options, args)
,但我怎麼可以指定file.txt的也是必需的?
非常感謝