File tree Expand file tree Collapse file tree
java/org/apache/commons/cli
test/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 *
2828 * @author John Keyes (john at integralsource.com)
2929 * @see Parser
30- * @version $Revision: 1.17 $
30+ * @version $Revision: 1.18 $
3131 */
3232public abstract class Parser implements CommandLineParser {
3333
@@ -243,7 +243,7 @@ private void processProperties(Properties properties)
243243 // get the value from the properties instance
244244 String value = properties .getProperty (option );
245245
246- if (opt .hasArgs ())
246+ if (opt .hasArg ())
247247 {
248248 if ((opt .getValues () == null )
249249 || (opt .getValues ().length == 0 ))
Original file line number Diff line number Diff line change 1919import java .io .PrintStream ;
2020import java .io .PrintWriter ;
2121import java .io .StringWriter ;
22+ import java .util .Properties ;
2223
2324import junit .framework .Test ;
2425import junit .framework .TestCase ;
@@ -479,5 +480,22 @@ public void test27635() {
479480 "footer" +EOL
480481 ,out .toString ());
481482 }
483+
484+ public void test31148 () throws ParseException {
485+ Option multiArgOption = new Option ("o" ,"option with multiple args" );
486+ multiArgOption .setArgs (1 );
487+
488+ Options options = new Options ();
489+ options .addOption (multiArgOption );
490+
491+ Parser parser = new PosixParser ();
492+ String [] args = new String []{};
493+ Properties props = new Properties ();
494+ props .setProperty ("o" ,"ovalue" );
495+ CommandLine cl = parser .parse (options ,args ,props );
496+
497+ assertTrue (cl .hasOption ('o' ));
498+ assertEquals ("ovalue" ,cl .getOptionValue ('o' ));
499+ }
482500
483501}
You can’t perform that action at this time.
0 commit comments