You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/12/04 04:41:24 UTC

DO NOT REPLY [Bug 15046] New: - MissingArgumentException: no argument for

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: commons-dev@jakarta.apache.org
        ReportedBy: ledestin@amur.ru


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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>