donaldp 01/04/01 18:33:28 Added: src/compat/org/apache/avalon/util/cli AbstractMain.java Log: Deprecated AbstractMain as it encouraged obfusicated code and did not really simplify using this package. Revision Changes Path 1.1 jakarta-avalon/src/compat/org/apache/avalon/util/cli/AbstractMain.java Index: AbstractMain.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 file. */ package org.apache.avalon.util.cli; import java.util.List; import org.apache.avalon.AbstractLoggable; /** * Abstract main entry point. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a> * @deprecated This class while convenient led to code that was * less than understandable. It is better to implement the * functionality manually. * */ public abstract class AbstractMain extends AbstractLoggable { protected CLOptionDescriptor[] m_options; /** * Return string describing how command is executed. * * @return the string describing exectution command */ protected String getExecutionCommand() { return "java " + getClass().getName() + " [options]"; } /** * Display usage report. * */ protected void usage() { System.out.println( getExecutionCommand() ); System.out.println( "\tAvailable options:"); System.out.println( CLUtil.describeOptions( m_options ) ); } /** * Initialise the options for command line parser. * */ protected abstract CLOptionDescriptor[] createCLOptions(); /** * Main entry point. * * @param args[] the command line arguments * @Throwable Throwable if an error occurs */ public void execute( final String[] args ) throws Exception { m_options = createCLOptions(); final CLArgsParser parser = new CLArgsParser( args, m_options ); if( null != parser.getErrorString() ) { System.err.println( "Error: " + parser.getErrorString() ); return; } execute( parser.getArguments() ); } /** * Overide this method to provide functionality for your application. * * @param clOptions the list of command line options */ protected abstract void execute( final List clOptions ) throws Exception; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]