jcmdline
Class TextUsageFormatter

java.lang.Object
  extended by jcmdline.TextUsageFormatter
All Implemented Interfaces:
UsageFormatter

public class TextUsageFormatter
extends java.lang.Object
implements UsageFormatter

Used to format a command's usage.

Version:
jcmdline Rel. 2.0.0 $Id: TextUsageFormatter.java,v 1.2 2002/12/07 14:22:06 lglawrence Exp $
Author:
Lynne Lawrence
See Also:
CmdLineHandler

Constructor Summary
TextUsageFormatter()
          constructor
 
Method Summary
 java.lang.String formatErrorMsg(java.lang.String msg)
          Gets an error message, reformatted in a manner to "go well with" the usage statement.
 java.lang.String formatText(java.lang.String text, int indent, int lineLen)
           
 java.lang.String formatUsage(java.lang.String cmdName, java.lang.String cmdDesc, java.util.Map<java.lang.String,Parameter<?>> opts, java.util.List<Parameter<?>> args, boolean showHidden)
          gets the usage for the command
 int getLineLength()
          Gets the maximum line length to use for usage display.
 void setLineLength(int lineLength)
          Sets the maximum line length to use for usage display - default is 80.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextUsageFormatter

public TextUsageFormatter()
constructor

Method Detail

formatErrorMsg

public java.lang.String formatErrorMsg(java.lang.String msg)
Gets an error message, reformatted in a manner to "go well with" the usage statement. This implementation returns:
    ERROR: invalid filename
 
when called as:
 formatErrorMsg("invalid filename")
 

Specified by:
formatErrorMsg in interface UsageFormatter
Parameters:
msg - the text of the error message
Returns:
the reformatted error message

formatText

public java.lang.String formatText(java.lang.String text,
                                   int indent,
                                   int lineLen)

formatUsage

public java.lang.String formatUsage(java.lang.String cmdName,
                                    java.lang.String cmdDesc,
                                    java.util.Map<java.lang.String,Parameter<?>> opts,
                                    java.util.List<Parameter<?>> args,
                                    boolean showHidden)
gets the usage for the command

Specified by:
formatUsage in interface UsageFormatter
Parameters:
cmdName - the command name
cmdDesc - the command description
opts - a Map of command options; keys are the option tags, values are the option objects
args - the command arguments
showHidden - if true, hidden parameters will be displayed
Returns:
the usage for the command

getLineLength

public int getLineLength()
Gets the maximum line length to use for usage display.

Specified by:
getLineLength in interface UsageFormatter
Returns:
the maximum line length to use for usage display
See Also:
setLineLength()

setLineLength

public void setLineLength(int lineLength)
Sets the maximum line length to use for usage display - default is 80.

Specified by:
setLineLength in interface UsageFormatter
Parameters:
lineLength - the maximum line length to use for usage display
See Also:
getLineLength()