You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Joe Weder <jw...@gbg.com> on 2004/10/29 17:47:53 UTC

Parsed Option missing value

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