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/examples/no_aliasing NoAlias.java README.txt
Date Tue, 19 Mar 2002 10:50:11 GMT
donaldp     02/03/19 02:50:11

  Added:       cli/examples/no_aliasing NoAlias.java README.txt
  Add no alias example
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/cli/examples/no_aliasing/NoAlias.java
  Index: NoAlias.java
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
  import java.util.List;
  import org.apache.avalon.excalibur.cli.CLArgsParser;
  import org.apache.avalon.excalibur.cli.CLOption;
  import org.apache.avalon.excalibur.cli.CLOptionDescriptor;
  import org.apache.avalon.excalibur.cli.CLUtil;
   * This simple example shows how to set it up so that only the
   * long form or only short form of an option is capable of
   * being used.
   * @author <a href="peter@apache.org">Peter Donald</a>
  public class NoAlias
      // Define our short one-letter option identifiers.
      private static final int SHORT_OPT = 's';
      private static final int LONG_OPT = 1;
      private static final CLOptionDescriptor[] OPTIONS = new CLOptionDescriptor[]
          new CLOptionDescriptor( null,
                                  "option with only short form",
                                  new int[ 0 ] ),
          new CLOptionDescriptor( "long",
                                  "option with long form" )
      public static void main( final String[] args )
          System.out.println( "Starting NoAlias..." );
          System.out.println( CLUtil.describeOptions( OPTIONS ) );
          // Parse the arguments
          final CLArgsParser parser = new CLArgsParser( args, OPTIONS );
          //Make sure that there was no errors parsing
          if( null != parser.getErrorString() )
              System.err.println( "Error: " + parser.getErrorString() );
          // Get a list of parsed options
          final List options = parser.getArguments();
          final int size = options.size();
          for( int i = 0; i < size; i++ )
              final CLOption option = (CLOption)options.get( i );
              switch( option.getId() )
                  case CLOption.TEXT_ARGUMENT:
                      //This occurs when a user supplies an argument that
                      //is not an option
                      System.out.println( "Unknown arg: " + option.getArgument() );
                  case SHORT_OPT:
                      System.out.println( "Received short option" );
                  case LONG_OPT:
                      System.out.println( "Received long option" );
  1.1                  jakarta-avalon-excalibur/cli/examples/no_aliasing/README.txt
  Index: README.txt
  Welcome to Excalibur CLI!
  As always, the if you have any questions :
  1) Make sure you followed any directions
  2) Review documentation included in this package, or online at
  3) Ask on the avalon-dev list.  This is a great source of support
     information. To join, read http://jakarta.apache.org/site/mail.html
     and then follow the link at the bottom to join the lists.
  This simple example shows how to set it up so that only the long form
  or only short form of an option is capable of being used.
  Compile it by running
  javac -classpath ../../build/lib/@dist.name@.jar *.java (Unix)
  javac -classpath ..\..\build\lib\@dist.name@.jar *.java (Windows)
  Run it using the scripts provided:
    java -classpath ../../build/lib/@dist.name@.jar:. NoAlias (Unix)
    java -classpath ..\..\build\lib\@dist.name@.jar;. NoAlias (Windows)
  Try passing it the "--help" command line option to see which other
  command line options are available. The experiment by passing in
  different options.
  Some combinations to try out include

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

View raw message