commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Weder <jwe...@gbg.com>
Subject Parsed Option missing value
Date Fri, 29 Oct 2004 15:47:53 GMT
Just started using CLI (the download is commons-cli-1.0.jar)

All was going well untill I encountered this problem demonstated below:

        Options ops = new Options();

         ops.addOption(  OptionBuilder
                            .withArgName("some-param")
                            .hasArg()
                            .withValueSeparator()
                            .withDescription("this is param 1" )
                            .isRequired(false)
                            .withLongOpt("param1")
                            .create("a"));

         ops.addOption(  OptionBuilder
                            .withArgName("some-other-param")
                            .hasArg()
                            .withValueSeparator()
                            .withDescription("this is param 2")
                            .isRequired(false)
                            .withLongOpt("param2")
                            .create("b"));

        CommandLineParser parser = new PosixParser();
        String[] args = new String[]{"-a=abc", "--param2=xyz"};
        CommandLine cmd = parser.parse(permittedOptions, args);
        Option[] t = cmd.getOptions();

When I use the getValue() on the Option instances that CommandLine 
returns, the "-a" option has "" as a value, but the "-b" has "xyz". 
Tried all kinds of permutations but anything I try using the short 
option, I get no value.

Suggestions?



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message