org.homeunix.thecave.moss.util
Class ParseCommands

java.lang.Object
  extended by org.homeunix.thecave.moss.util.ParseCommands

public class ParseCommands
extends java.lang.Object

This class makes Unix style command line parsing easy for Java applications. Please see below for instructions on how to use it.

For a copy of the LGPL license, please see http://www.gnu.org/copyleft/lesser.html

Copyright (C) 2005 by Wyatt Olson

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA To use, simply create a collection of ParseVariable objects of the correct types, and pass them to the static parse() method. The return value of this is a ParseResults object, which you can then extract the values from.

Author:
wyatt

Nested Class Summary
static class ParseCommands.ParseResults
           
static class ParseCommands.ParseVariable
           
 
Constructor Summary
ParseCommands()
           
 
Method Summary
static ParseCommands.ParseResults parse(java.lang.String[] args, java.lang.String help, java.util.Collection<ParseCommands.ParseVariable> flags)
          Parses command line arguments, and returns them as a mapping of flag (-x) to variable.
static ParseCommands.ParseResults parse(java.lang.String[] args, java.lang.String help, ParseCommands.ParseVariable... flags)
          Parses command line arguments, and returns them as a mapping of flag (-x) to variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseCommands

public ParseCommands()
Method Detail

parse

public static ParseCommands.ParseResults parse(java.lang.String[] args,
                                               java.lang.String help,
                                               java.util.Collection<ParseCommands.ParseVariable> flags)
Parses command line arguments, and returns them as a mapping of flag (-x) to variable. The input variables within flagVariables should be Objects (eg, Integer instead of int). Currently Boolean, Integer, String, Double , Character, and Float are supported; it is simple to add more as required.

Parameters:
args - Command line argument as given to the main method
help - The usage instructions which are shown if the command is type incorrectly.
flags - Collection of ParseVariables to define which flags to look for.
Returns:
Throws:
ParseException

parse

public static ParseCommands.ParseResults parse(java.lang.String[] args,
                                               java.lang.String help,
                                               ParseCommands.ParseVariable... flags)
Parses command line arguments, and returns them as a mapping of flag (-x) to variable. The input variables within flagVariables should be Objects (eg, Integer instead of int). Currently Boolean, Integer, String, Double , Character, and Float are supported; it is simple to add more as required.

Parameters:
args - Command line argument as given to the main method
help - The usage instructions which are shown if the command is type incorrectly.
flags - One or more ParseVariables to define which flags to look for.
Returns:
Throws:
ParseException