edu.umn.cs.nlp.util
Class CommandLineParser

java.lang.Object
  extended by edu.umn.cs.nlp.util.CommandLineParser

public class CommandLineParser
extends Object

Java Command Line Parser

The current version supports string and integer options.

Support is not included for options which take a list of values.

Version:
$LastChangedDate: 2007-11-14 09:28:40 -0600 (Wed, 14 Nov 2007) $
Author:
Lane O.B. Schwartz

Nested Class Summary
 class CommandLineParser.CommandLineParserException
           
 class CommandLineParser.DuplicateOptionException
           
 class CommandLineParser.Option<OptionType>
           
 
Constructor Summary
CommandLineParser()
           
CommandLineParser(Set<String> localizedTrueStrings, Set<String> localizedFalseStrings)
           
 
Method Summary
 CommandLineParser.Option<Boolean> addBooleanOption(char shortForm)
           
 CommandLineParser.Option<Boolean> addBooleanOption(char shortForm, String longForm)
           
 CommandLineParser.Option<Boolean> addBooleanOption(char shortForm, String longForm, String comment)
           
 CommandLineParser.Option<Boolean> addBooleanOption(char shortForm, String longForm, String valueVariable, Boolean defaultValue, String comment)
           
 CommandLineParser.Option<Boolean> addBooleanOption(char shortForm, String longForm, String valueVariable, String comment)
           
 CommandLineParser.Option<Boolean> addBooleanOption(String longForm)
           
 CommandLineParser.Option<Boolean> addBooleanOption(String longForm, Boolean defaultValue, String comment)
           
 CommandLineParser.Option<Boolean> addBooleanOption(String longForm, String comment)
           
 CommandLineParser.Option<Boolean> addBooleanOption(String longForm, String valueVariable, Boolean defaultValue, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm, String valueVariable, Integer defaultValue, Set<Integer> legalValues, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm, String valueVariable, Integer defaultValue, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm, String valueVariable, Set<Integer> legalValues, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(char shortForm, String longForm, String valueVariable, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(String longForm)
           
 CommandLineParser.Option<Integer> addIntegerOption(String longForm, String comment)
           
 CommandLineParser.Option<Integer> addIntegerOption(String longForm, String valueVariable, Integer defaultValue, String comment)
           
 CommandLineParser.Option<String> addStringOption(char shortForm)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm, String comment)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm, String valueVariable, Set<String> legalValues, String comment)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm, String valueVariable, String comment)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm, String valueVariable, String defaultValue, Set<String> legalValues, String comment)
           
 CommandLineParser.Option<String> addStringOption(char shortForm, String longForm, String valueVariable, String defaultValue, String comment)
           
 CommandLineParser.Option<String> addStringOption(String longForm)
           
 CommandLineParser.Option<String> addStringOption(String longForm, String comment)
           
 CommandLineParser.Option<String> addStringOption(String longForm, String valueVariable, String defaultValue, String comment)
           
<OptionType>
OptionType
getValue(CommandLineParser.Option<OptionType> option)
           
 boolean hasValue(CommandLineParser.Option<?> option)
           
static void main(String[] args)
           
 void parse(String[] argv)
           
 CommandLineParser.Option parseLongForm(String key)
           
 CommandLineParser.Option parseLongForm(String key, String value)
           
 CommandLineParser.Option parseShortForm(Character key)
           
 CommandLineParser.Option parseShortForm(Character key, String value)
           
 void printUsage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineParser

public CommandLineParser()

CommandLineParser

public CommandLineParser(Set<String> localizedTrueStrings,
                         Set<String> localizedFalseStrings)
Method Detail

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          Integer defaultValue,
                                                          Set<Integer> legalValues,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          Set<Integer> legalValues,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          Integer defaultValue,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(String longForm,
                                                          String valueVariable,
                                                          Integer defaultValue,
                                                          String comment)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm,
                                                          String longForm)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(char shortForm)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(String longForm)

addIntegerOption

public CommandLineParser.Option<Integer> addIntegerOption(String longForm,
                                                          String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm,
                                                        String valueVariable,
                                                        String defaultValue,
                                                        Set<String> legalValues,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm,
                                                        String valueVariable,
                                                        Set<String> legalValues,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm,
                                                        String valueVariable,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm,
                                                        String valueVariable,
                                                        String defaultValue,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(String longForm,
                                                        String valueVariable,
                                                        String defaultValue,
                                                        String comment)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm,
                                                        String longForm)

addStringOption

public CommandLineParser.Option<String> addStringOption(char shortForm)

addStringOption

public CommandLineParser.Option<String> addStringOption(String longForm)

addStringOption

public CommandLineParser.Option<String> addStringOption(String longForm,
                                                        String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          Boolean defaultValue,
                                                          String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(char shortForm,
                                                          String longForm,
                                                          String valueVariable,
                                                          String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(char shortForm,
                                                          String longForm,
                                                          String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(String longForm,
                                                          Boolean defaultValue,
                                                          String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(String longForm,
                                                          String valueVariable,
                                                          Boolean defaultValue,
                                                          String comment)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(char shortForm,
                                                          String longForm)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(char shortForm)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(String longForm)

addBooleanOption

public CommandLineParser.Option<Boolean> addBooleanOption(String longForm,
                                                          String comment)

parse

public void parse(String[] argv)

printUsage

public void printUsage()

parseLongForm

public CommandLineParser.Option parseLongForm(String key,
                                              String value)

parseLongForm

public CommandLineParser.Option parseLongForm(String key)

parseShortForm

public CommandLineParser.Option parseShortForm(Character key)

parseShortForm

public CommandLineParser.Option parseShortForm(Character key,
                                               String value)

getValue

public <OptionType> OptionType getValue(CommandLineParser.Option<OptionType> option)

hasValue

public boolean hasValue(CommandLineParser.Option<?> option)

main

public static void main(String[] args)