com.svincent.util
Class CommandLine

java.lang.Object
  |
  +--com.svincent.util.CommandLine

public class CommandLine
extends java.lang.Object

A class which provides facilities for processing command line arguments.

To do:


Inner Class Summary
static class CommandLine.Arg
          An Arg represents the definition of a potential argument on the command line.
static class CommandLine.ArgRedefinedException
           
static class CommandLine.BooleanArg
           
static class CommandLine.CommandLineException
           
static class CommandLine.IntArg
           
static class CommandLine.ParseException
           
static class CommandLine.StringArg
           
static class CommandLine.TypeException
           
 
Field Summary
protected  int allowedLeftovers
          How many leftovers are allowed (-1 means any number).
static boolean debug
           
protected  java.io.PrintWriter err
          Where to print error messages.
protected  java.util.List leftovers
           
protected  java.util.Map longArgs
           
protected  java.util.List resultArgs
          A list of Strings and Args, representing the parsed args, in order.
protected  java.util.Map shortArgs
           
protected  boolean strict
          True iff unknown arguments represent an error.
protected  java.lang.Class user
          The user of this CommandLine.
 
Constructor Summary
CommandLine(java.lang.Class _user)
           
CommandLine(java.lang.Class _user, java.io.PrintWriter _err, boolean _strict)
           
 
Method Summary
 void addArg(CommandLine.Arg arg)
           
 java.util.List getAllArgs()
          Returns a sorted list of all the Arg objects.
 CommandLine.Arg getArg(java.lang.String longArg)
           
 boolean getBooleanArg(java.lang.String longArg)
           
 int getIntArg(java.lang.String longArg)
           
 java.lang.String[] getLeftovers()
           
 java.util.List getResultArgs()
           
 java.lang.String getStringArg(java.lang.String longArg)
           
static void main(java.lang.String[] args)
          Print out the args, using this guy's fancy arg-scheme.
protected  void printError(java.lang.String msg)
           
 void printUsage(java.io.PrintWriter out)
           
 boolean process(java.lang.String[] args)
          Return true iff there were no errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static final boolean debug

user

protected java.lang.Class user
The user of this CommandLine. Used for printing usage messages.

err

protected java.io.PrintWriter err
Where to print error messages.

strict

protected boolean strict
True iff unknown arguments represent an error.

longArgs

protected java.util.Map longArgs

shortArgs

protected java.util.Map shortArgs

allowedLeftovers

protected int allowedLeftovers
How many leftovers are allowed (-1 means any number).

leftovers

protected java.util.List leftovers

resultArgs

protected java.util.List resultArgs
A list of Strings and Args, representing the parsed args, in order.
Constructor Detail

CommandLine

public CommandLine(java.lang.Class _user)

CommandLine

public CommandLine(java.lang.Class _user,
                   java.io.PrintWriter _err,
                   boolean _strict)
Method Detail

getAllArgs

public java.util.List getAllArgs()
Returns a sorted list of all the Arg objects.

getResultArgs

public java.util.List getResultArgs()

addArg

public void addArg(CommandLine.Arg arg)

process

public boolean process(java.lang.String[] args)
Return true iff there were no errors.

getArg

public CommandLine.Arg getArg(java.lang.String longArg)

getBooleanArg

public boolean getBooleanArg(java.lang.String longArg)

getStringArg

public java.lang.String getStringArg(java.lang.String longArg)

getIntArg

public int getIntArg(java.lang.String longArg)

getLeftovers

public java.lang.String[] getLeftovers()

printError

protected void printError(java.lang.String msg)

printUsage

public void printUsage(java.io.PrintWriter out)

main

public static void main(java.lang.String[] args)
Print out the args, using this guy's fancy arg-scheme.



This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/

Copyright © 1999 Shawn P. Vincent.

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