commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CLI-137) Change of behaviour 1.0 -> 1.1
Date Mon, 02 Jun 2008 20:31:45 GMT

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

ebourg edited comment on CLI-137 at 6/2/08 1:30 PM:
------------------------------------------------------------

Here is the patch I intend to apply, I put it here first for review. CommandLine not longer
stores the options in a Set, and the parsers clone the options matched. The consequences are:
- CommandLine.iterator() may return the same option more than once, with different arguments.
This is like CLI 1.0
- the hasArgs( n ) semantic is 'n arguments per occurrence', and not ' n arguments for all
occurrences' of the option. This is like CLI 1.0
- the option put in the Options instance before parsing the command line no longer receives
any argument. The right way of querying the option is to use the CommandLine instance. (this
breaks test15046() in BugsTest, but this isn't the purpose of this test)



      was (Author: ebourg):
    Here is the patch I intend to apply, I put it here first for review. CommandLine not longer
stores the options in a Set, and the parsers clone the options matched. The consequences are:
- CommandLine.iterator() may return the same option more than once, with different arguments.
This is like CLI 1.0
- the hasArgs(n) semantic is 'n arguments per occurrence', and not ' n arguments for all occurrences'
of the option. This is like CLI 1.0
- the option put in the Options instance before parsing the command line no longer receives
any argument. The right way of querying the option is to use the CommandLine instance. (this
breaks test15046() in BugsTest, but this isn't the purpose of this test)


  
> Change of behaviour 1.0 -> 1.1
> ------------------------------
>
>                 Key: CLI-137
>                 URL: https://issues.apache.org/jira/browse/CLI-137
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x
>    Affects Versions: 1.1
>         Environment: Ubuntu 7.04 Feisty Fawn (JDK 1.6.0) + Commons CLI 1.0 and 1.1
>            Reporter: Russel Winder
>            Priority: Blocker
>             Fix For: 1.2
>
>         Attachments: repeated-options.patch
>
>
> The code:
> {code}
> import org.apache.commons.cli.*;
> public class Trial {
>   private void execute (String[] commandLine) throws ParseException {
>     Options options = new Options();
>     options.addOption ( OptionBuilder.withLongOpt("flob").hasArg().create('F') );
>     CommandLine line = new GnuParser().parse(options, commandLine);
>     String[] results = line.getOptionValues('F');
>     if ( results != null ) { 
>       for ( String s : results ) { 
>         System.out.println( "-F " + s );
>       } 
>     }
>     results = line.getOptionValues("flob") ;
>     if ( results != null ) { 
>       for ( String s : results ) { 
>         System.out.println( "--blah " + s ); 
>       }
>     }
>     String[] theRest = line.getArgs() ;
>     for ( String s : theRest ) { 
>       System.out.print( s + " " ); 
>     }
>     System.out.println();
>   }
>   public static void main (String[] args) throws ParseException {
>     Trial trial = new Trial() ;
>     trial.execute ( new String[] { "-F1" , "-F3" , "-Fbla" , "-F 76" , "--flob" , "54"
} ) ;
>   }
> }
> {code}
> when compiled and executed under 1.0 produces:
> trial:
>      [java] -F 1
>      [java] -F 3
>      [java] -F bla
>      [java] -F  76
>      [java] -F 54
>      [java] 
> However, when compiled and executed under 1.1 produces:
> trial:
>      [java] -F 1
>      [java] --blah 1
>      [java] 3 bla  76 54 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message