net.sf.mmm.util.cli.base
Class AbstractCliParser.CliHelpWriter

java.lang.Object
  extended by net.sf.mmm.util.cli.base.AbstractCliParser.CliHelpWriter
Enclosing class:
AbstractCliParser

public static class AbstractCliParser.CliHelpWriter
extends Object

This inner class is a helper to simplify writing the help-usage.


Field Summary
private  Appendable appendable
          The Appendable where to write help to.
private  Map<String,Object> arguments
          The NLS-arguments.
private  CliParserDependencies dependencies
          The CliParserDependencies.
private  TextColumnInfo mainColumnInfo
          The TextColumnInfo for the main column.
private  TextColumnInfo parameterColumnInfo
          The TextColumnInfo for parameters (e.g.
private  Object state
          The state-object.
private  TextTableInfo tableInfo
          The TextTableInfo.
 
Constructor Summary
AbstractCliParser.CliHelpWriter(Appendable appendable, CliOutputSettings settings, CliParserDependencies dependencies, CliState cliState, Object state)
          The constructor.
 
Method Summary
 Map<String,Object> getArguments()
           
 void printArguments(List<AbstractCliParser.CliArgumentHelpInfo> argumentList, int maxArgumentColumnWidth)
          This method prints the help for the arguments given by argumentList.
 void println()
          Prints a newline (terminates current line).
private  void printOptions(Collection<CliOptionContainer> modeOptions, Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap, boolean required)
          This method is like printOptions(Collection, Map, int) but only prints required or additional options.
 void printOptions(Collection<CliOptionContainer> modeOptions, Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap, int maxOptionColumnWidth)
          This method prints the help for the options given by modeOptions.
 void printText(String nlsText)
          This method performs localization of the given NLS-text (see AbstractResourceBundle) and performs line-wrapping while writing it to the Appendable for help-usage output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appendable

private final Appendable appendable
The Appendable where to write help to.


tableInfo

private final TextTableInfo tableInfo
The TextTableInfo.


parameterColumnInfo

private final TextColumnInfo parameterColumnInfo
The TextColumnInfo for parameters (e.g. "--help (-h)").


mainColumnInfo

private final TextColumnInfo mainColumnInfo
The TextColumnInfo for the main column.


dependencies

private final CliParserDependencies dependencies
The CliParserDependencies.


arguments

private final Map<String,Object> arguments
The NLS-arguments.


state

private final Object state
The state-object.

Constructor Detail

AbstractCliParser.CliHelpWriter

public AbstractCliParser.CliHelpWriter(Appendable appendable,
                                       CliOutputSettings settings,
                                       CliParserDependencies dependencies,
                                       CliState cliState,
                                       Object state)
The constructor.

Parameters:
appendable - is the Appendable where to write help to.
settings - is the CliOutputSettings.
dependencies - are the CliParserDependencies.
cliState - is the CliState.
state - is the state-object.
Method Detail

getArguments

public Map<String,Object> getArguments()
Returns:
the arguments

printText

public void printText(String nlsText)
This method performs localization of the given NLS-text (see AbstractResourceBundle) and performs line-wrapping while writing it to the Appendable for help-usage output.

Parameters:
nlsText - is the internationalized text to print.

printArguments

public void printArguments(List<AbstractCliParser.CliArgumentHelpInfo> argumentList,
                           int maxArgumentColumnWidth)
This method prints the help for the arguments given by argumentList. It prints them with localized usage texts in a two column-layout via LineWrapper.

Parameters:
argumentList - is the List with the according help infos.
maxArgumentColumnWidth - is the maximum width of the argument-name column.

printOptions

public void printOptions(Collection<CliOptionContainer> modeOptions,
                         Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap,
                         int maxOptionColumnWidth)
This method prints the help for the options given by modeOptions. It prints them with localized usage texts in a two column-layout via LineWrapper.

Parameters:
modeOptions - is the Collection with the options to print.
option2HelpMap - is the Map with the according help infos.
maxOptionColumnWidth - is the maximum width of the option-syntax column.

printOptions

private void printOptions(Collection<CliOptionContainer> modeOptions,
                          Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap,
                          boolean required)
This method is like printOptions(Collection, Map, int) but only prints required or additional options.

Parameters:
modeOptions - is the Collection with the options to print.
option2HelpMap - is the Map with the according help infos.
required - - true if required options should be printed, false if additional options should be printed.

println

public void println()
Prints a newline (terminates current line).



Copyright © 2001-2010 mmm-Team. All Rights Reserved.