[ 
https://issues.apache.org/jira/browse/CLI-255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15382950#comment-15382950
 ] 

Alexander Prishchepov commented on CLI-255:
-------------------------------------------

I was using GnuParser with CLI1.2, but it is deprecated in CLI1.3
After discovering the issue, had to move back to GnuParser.

I am ok to provide a patch, but not sure what is the idea behind moving 
everybody to DefaultParser in CLI1.3
Even though that the issue is not a bug, but planned API change.

Any comments from original author?

> 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.3.1
>            Reporter: Alexander Prishchepov
>            Priority: Minor
>
> If I have options with long name and single hyphen, DefaultParser does not 
> recognize them after a list of unlimited arguments.
> Here is the test case:
> {code:java}
>     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);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to