laser.util.commandline
Class CommandLine

java.lang.Object
  extended by laser.util.commandline.CommandLine

public class CommandLine
extends java.lang.Object

Implements a simple (and stupid) command line argument parser. The parser assumes that a command line is a set of "-key value" pairs. Each key is permitted to occur multiple times in the same command. This should probably be improved later on to make is more robust. If args is empty, parse assumes that the args will be read from System.in.

NOTE: If the args are read from System.in, then:

  1. Each line is tokenized by white space.
  2. Each argument must be either a quoted or unquoted string.
  3. An argument cannot contain quotes within it.
  4. An argument is not processed for escaped character sequences.

Author:
Jamieson M. Cobleigh (laser-software@cs.umass.edu)

Constructor Summary
CommandLine()
           
 
Method Summary
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> parse(java.lang.String[] args)
          Parses the command line arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLine

public CommandLine()
Method Detail

parse

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> parse(java.lang.String[] args)
                                                                              throws java.io.IOException
Parses the command line arguments. They are unmodifiable.

Parameters:
args - The arguments to be parsed
Returns:
A Map whose keys are the keys on the commandline and whose values are Lists of Strings that go with that key
Throws:
java.io.IOException - if an I/O error occurs while reading from System.in