commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13886] New: - No way to make OptionGroup mandatory.
Date Wed, 23 Oct 2002 16:14:50 GMT
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=13886>.
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=13886

No way to make OptionGroup mandatory.

           Summary: No way to make OptionGroup mandatory.
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: CLI
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: gence.soysal@syntegra.com


See javadoc below:

package test;

import org.apache.commons.cli.*;

/**
 * @author Gence Soysal
 *
 * Test case for org.apache.commons.cli package lack of support for mandatory
 * option groups. Run with -a to get a MissingOptionException, run with -a -b -c
 * to get an AlreadySelectedException. Ideally, OptionGroup would have a
 * mandatory property as well. If not feasible, then setting all options inside
 * a mutually exclusive option group to mandatory should not throw a 
 * MissingOptionException when the parser is supplied with only one of those 
options.
 */
public class MandatoryOptionGroupTest {
	public static void main(String[] args) {
			Options options = new Options();
			Option option;
			OptionGroup optionGroup = new OptionGroup();
			
	
			option = new Option("a", false, "Desc A", true);
			optionGroup.addOption(option);
			option = new Option("b", false, "Desc B", true);
			optionGroup.addOption(option);
			option = new Option("c", false, "Desc C", true);
			optionGroup.addOption(option);
			
			options.addOptionGroup(optionGroup);
			
			Parser parser = new GnuParser();
			
			try {
				parser.parse(options, args);
			} catch (ParseException e) {
				System.out.println("Error: " + e.getMessage());
				System.exit(1);
			}
			
			System.out.println("Success");
		}
	}

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message