|
1 | 1 | /* |
2 | | - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/Parser.java,v 1.9 2002/11/25 23:43:40 jkeyes Exp $ |
3 | | - * $Revision: 1.9 $ |
4 | | - * $Date: 2002/11/25 23:43:40 $ |
| 2 | + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/Parser.java,v 1.10 2002/11/27 23:22:02 jkeyes Exp $ |
| 3 | + * $Revision: 1.10 $ |
| 4 | + * $Date: 2002/11/27 23:22:02 $ |
5 | 5 | * |
6 | 6 | * ==================================================================== |
7 | 7 | * |
|
74 | 74 | * |
75 | 75 | * @author John Keyes (john at integralsource.com) |
76 | 76 | * @see Parser |
77 | | - * @version $Revision: 1.9 $ |
| 77 | + * @version $Revision: 1.10 $ |
78 | 78 | */ |
79 | 79 | public abstract class Parser implements CommandLineParser { |
80 | 80 |
|
@@ -255,9 +255,28 @@ private void processProperties( Properties properties ) { |
255 | 255 | String option = e.nextElement().toString(); |
256 | 256 | if( !cmd.hasOption( option ) ) { |
257 | 257 | Option opt = options.getOption( option ); |
258 | | - if( opt.getValues() == null || opt.getValues().length == 0 ) { |
259 | | - opt.addValue( properties.getProperty( option ) ); |
| 258 | + |
| 259 | + // get the value from the properties instance |
| 260 | + String value = properties.getProperty( option ); |
| 261 | + |
| 262 | + if( opt.hasArgs() ) { |
| 263 | + if( opt.getValues() == null || opt.getValues().length == 0 ) { |
| 264 | + try { |
| 265 | + opt.addValue( value ); |
| 266 | + } |
| 267 | + catch( RuntimeException exp ) { |
| 268 | + // if we cannot add the value don't worry about it |
| 269 | + } |
| 270 | + } |
260 | 271 | } |
| 272 | + else if ( ! ( "yes".equalsIgnoreCase( value ) || |
| 273 | + "true".equalsIgnoreCase( value ) || |
| 274 | + "1".equalsIgnoreCase( value) ) ) { |
| 275 | + // if the value is not yes, true or 1 then don't add the |
| 276 | + // option to the CommandLine |
| 277 | + break; |
| 278 | + } |
| 279 | + |
261 | 280 | cmd.addOption( opt ); |
262 | 281 | } |
263 | 282 | } |
|
0 commit comments