avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/cli/src/java/org/apache/avalon/excalibur/cli CLOptionDescriptor.java
Date Wed, 20 Mar 2002 09:42:05 GMT
donaldp     02/03/20 01:42:05

  Modified:    cli/src/java/org/apache/avalon/excalibur/cli
                        CLOptionDescriptor.java
  Log:
  Make sure options cant have dodgy combination of modes specified
  
  Revision  Changes    Path
  1.9       +29 -0     jakarta-avalon-excalibur/cli/src/java/org/apache/avalon/excalibur/cli/CLOptionDescriptor.java
  
  Index: CLOptionDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cli/src/java/org/apache/avalon/excalibur/cli/CLOptionDescriptor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CLOptionDescriptor.java	19 Mar 2002 11:07:07 -0000	1.8
  +++ CLOptionDescriptor.java	20 Mar 2002 09:42:05 -0000	1.9
  @@ -71,6 +71,35 @@
           m_flags = flags;
           m_description = description;
           m_incompatible = incompatable;
  +
  +        int modeCount = 0;
  +        if( (ARGUMENT_REQUIRED & flags) == ARGUMENT_REQUIRED )
  +        {
  +            modeCount++;
  +        }
  +        if( (ARGUMENT_OPTIONAL & flags) == ARGUMENT_OPTIONAL )
  +        {
  +            modeCount++;
  +        }
  +        if( (ARGUMENT_DISALLOWED & flags) == ARGUMENT_DISALLOWED )
  +        {
  +            modeCount++;
  +        }
  +        if( (ARGUMENTS_REQUIRED_2 & flags) == ARGUMENTS_REQUIRED_2 )
  +        {
  +            modeCount++;
  +        }
  +
  +        if( 0 == modeCount )
  +        {
  +            final String message = "No mode specified for option " + this;
  +            throw new IllegalStateException( message );
  +        }
  +        else if( 1 != modeCount )
  +        {
  +            final String message = "Multiple modes specified for option " + this;
  +            throw new IllegalStateException( message );
  +        }
       }
   
       /**
  
  
  

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


Mime
View raw message