DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15046>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15046

MissingArgumentException: no argument for <option> is thrown when the option's 
parameter equals to an existing option.

           Summary: MissingArgumentException: no argument for <option> is
                    thrown when the option's parameter equals to an existing
                    option.
           Product: Commons
           Version: 1.0 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: CLI
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


MissingArgumentException: no argument for <option> is thrown when the option's
parameter equals to an existing option. Example:
-l option1
-m option2

//this will throw exception
$app -l m

Test case follows:
import junit.framework.*;
import org.apache.log4j.*;
import org.apache.commons.cli.*;

public class CliTest extends TestCase {
        CommandLineParser parser;
        
        public CliTest(String name) {
                super(name);
        }
        protected void setUp() throws Exception {
                parser = new PosixParser();
        }
        public void testParamNamedAsOption() throws Exception {
                final String[] CLI_ARGS = new String[] {"-z", "c"};
                Option option = new Option("z", "timezone", true, 
                        "affected option");
                Options cliOptions = new Options();
                cliOptions.addOption(option);
                parser.parse(cliOptions, CLI_ARGS);
                
                //now add conflicting option
                cliOptions.addOption("c", "conflict", true, "conflict option");
                parser.parse(cliOptions, CLI_ARGS);
        }
}

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to