You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alexander Prishchepov (JIRA)" <ji...@apache.org> on 2015/06/23 16:08:00 UTC
[jira] [Created] (CLI-255) DefaultParser, option with long name and
single dash, unlimited arguments
Alexander Prishchepov created CLI-255:
-----------------------------------------
Summary: DefaultParser, option with long name and single dash, unlimited arguments
Key: CLI-255
URL: https://issues.apache.org/jira/browse/CLI-255
Project: Commons CLI
Issue Type: Bug
Components: Parser
Affects Versions: 1.3.1, 1.3
Reporter: Alexander Prishchepov
Priority: Minor
If I have options with long name and single dash, DefaultParser does not recognize them after a list of unlimited arguments.
Here is the test case:
---------------------------
public void testUnlimitedArgs() throws Exception
{
String[] args = new String[] {"-unlimitedOne", "one", "two", "-unlimitedTwo",
"alpha"};
Options options = new Options();
options.addOption(Option.builder("unlimitedOne").hasArgs().build());
options.addOption(Option.builder("unlimitedTwo").hasArgs().build());
CommandLine cl = parser.parse(options, args);
assertTrue("Confirm -unlimitedOne is set", cl.hasOption("unlimitedOne"));
assertEquals("number of arg for -unlimitedOne", 2,
cl.getOptionValues("unlimitedOne").length);
assertTrue("Confirm -unlimitedTwo is set", cl.hasOption("unlimitedTwo"));
assertEquals("number of arg for -unlimitedTwo", 1,
cl.getOptionValues("unlimitedTwo").length);
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)