commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Parser.java
Date Wed, 27 Nov 2002 23:22:02 GMT
jkeyes      2002/11/27 15:22:02

  Modified:    cli/src/java/org/apache/commons/cli Parser.java
  Log:
  added support for *boolean/flag* options from properties
  
  Revision  Changes    Path
  1.10      +25 -6     jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Parser.java	25 Nov 2002 23:43:40 -0000	1.9
  +++ Parser.java	27 Nov 2002 23:22:02 -0000	1.10
  @@ -255,9 +255,28 @@
               String option = e.nextElement().toString();
               if( !cmd.hasOption( option ) ) {
                   Option opt = options.getOption( option );
  -                if( opt.getValues() == null || opt.getValues().length == 0 ) {
  -                    opt.addValue( properties.getProperty( option ) );
  +
  +                // get the value from the properties instance
  +                String value = properties.getProperty( option );
  +
  +                if( opt.hasArgs() ) {
  +                    if( opt.getValues() == null || opt.getValues().length == 0 ) {
  +                        try {
  +                            opt.addValue( value );
  +                        }
  +                        catch( RuntimeException exp ) {
  +                            // if we cannot add the value don't worry about it
  +                        }
  +                    }
                   }
  +                else if ( ! ( "yes".equalsIgnoreCase( value ) ||
  +                              "true".equalsIgnoreCase( value ) ||
  +                              "1".equalsIgnoreCase( value) ) ) {
  +                    // if the value is not yes, true or 1 then don't add the
  +                    // option to the CommandLine
  +                    break;
  +                }
  +
                   cmd.addOption( opt );
               }
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message