|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.programs.UtilCommandLine
Random functions for parsing, casting, verification and notification of values from org.apache.commons.cli.CommandLine
. See org.apache.commons.cli.CommandLine
.
Source code: UtilCommandLine.java
How to pass a dash in as the first character in a value (as in a negative number)?
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
UtilCommandLine(Options o_ptions,
int i_width,
String s_cmdLineSyntax,
String s_header,
String s_footer)
|
|
UtilCommandLine(Options o_ptions,
int i_width,
String s_cmdLineSyntax,
String s_header,
String s_footer,
boolean b_autoUsage)
|
|
UtilCommandLine(Options o_ptions,
PrintWriter print_writer,
int i_width,
String s_cmdLineSyntax,
String s_header,
String s_footer,
int i_leftPad,
int i_descPad)
|
|
UtilCommandLine(Options o_ptions,
PrintWriter print_writer,
int i_width,
String s_cmdLineSyntax,
String s_header,
String s_footer,
int i_leftPad,
int i_descPad,
boolean b_autoUsage)
|
|
UtilCommandLine(Options o_ptions,
String s_cmdLineSyntax)
|
|
UtilCommandLine(Options o_ptions,
String s_cmdLineSyntax,
boolean b_autoUsage)
|
|
UtilCommandLine(Options o_ptions,
String s_cmdLineSyntax,
String s_header,
String s_footer)
|
|
UtilCommandLine(Options o_ptions,
String s_cmdLineSyntax,
String s_header,
String s_footer,
boolean b_autoUsage)
|
Method Summary | |
void |
crash()
Stop execution, and print out usage. |
void |
crash(String s_error)
Stop execution, and print out usage. |
boolean |
getAutoUsage()
Get the auto-usage value, exactly as provided to the constructor. |
String |
getCmdLineSyntax()
Get the command-line syntax string, exactly as provided to the constructor. |
CommandLine |
getCommandLine()
Get the CommandLine, as previously parsed. |
CommandLine |
getCommandLine(String[] as_cmdLineParams)
Get the CommandLine after parsing the actually-provided command line. |
CommandLine |
getCommandLine(String[] as_cmdLineParams,
CommandLineParser cmd_linePrsr)
Get the CommandLine after parsing the actually-provided command line. |
int |
getDescPad()
Get the description-pad value, exactly as provided to the constructor. |
String |
getFooter()
Get the footer string, exactly as provided to the constructor. |
String |
getHeader()
Get the header string, exactly as provided to the constructor. |
int |
getInt(String s_optionName)
Get the int value of a parameter. |
int |
getInt(String s_optionName,
boolean b_useDefaultValue,
int i_defaultValue,
RangeConfig range_config)
Get the int value of a parameter. |
int |
getInt(String s_optionName,
int i_defaultValue)
Get the int value of a parameter. |
int |
getInt(String s_optionName,
int i_defaultValue,
RangeConfig range_config)
Get the int value of a parameter, which must conform to a range. |
int |
getInt(String s_optionName,
RangeConfig range_config)
Get the int value of a parameter, which must conform to a range. |
int |
getLeftPad()
Get the left-pad value, exactly as provided to the constructor. |
Options |
getOptions()
Get the Options, exactly as provided to the constructor. |
Outputter |
getOSDOOrOSDOAndFile(String s_optionName)
Get an Outputter to write to screen only, or both to screen and file. |
Outputter |
getOSDOOrOSDOAndFile(String s_optionName,
boolean b_appendToFile)
Get an Outputter to write to screen only, or both to screen and file. |
PrintWriter |
getPrintWriter()
Get the PrintWriter, exactly as provided to the constructor. |
int |
getWidth()
Get the width value, exactly as provided to the constructor. |
void |
printHelp()
Print out the usage string. |
void |
printHelp(String s_error)
Print out the usage string, plus an optional error message. |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UtilCommandLine(Options o_ptions, String s_cmdLineSyntax)
public UtilCommandLine(Options o_ptions, String s_cmdLineSyntax, boolean b_autoUsage)
public UtilCommandLine(Options o_ptions, String s_cmdLineSyntax, String s_header, String s_footer)
public UtilCommandLine(Options o_ptions, String s_cmdLineSyntax, String s_header, String s_footer, boolean b_autoUsage)
public UtilCommandLine(Options o_ptions, int i_width, String s_cmdLineSyntax, String s_header, String s_footer)
public UtilCommandLine(Options o_ptions, int i_width, String s_cmdLineSyntax, String s_header, String s_footer, boolean b_autoUsage)
public UtilCommandLine(Options o_ptions, PrintWriter print_writer, int i_width, String s_cmdLineSyntax, String s_header, String s_footer, int i_leftPad, int i_descPad)
public UtilCommandLine(Options o_ptions, PrintWriter print_writer, int i_width, String s_cmdLineSyntax, String s_header, String s_footer, int i_leftPad, int i_descPad, boolean b_autoUsage)
Method Detail |
public final CommandLine getCommandLine(String[] as_cmdLineParams)
Get the CommandLine after parsing the actually-provided command line.
getCommandLine(as_cmdLineParams, (new BasicParser()))
public final CommandLine getCommandLine(String[] as_cmdLineParams, CommandLineParser cmd_linePrsr)
Get the CommandLine after parsing the actually-provided command line.
In order, this first outputs the actually-provided command line, parses the actually-provided command line (and crashes with the usage message if anything is wrong), and then returns the derived CommandLine, as returned by cmd_linePrsr.parse()
.
This should only be called once. Second and subsequent requests for the CommandLine object should use getCommandLine instead.
as_cmdLineParams
- The array of command line parameters, provided directly from the 'main' function in your application. May not be null.cmd_linePrsr
- The CommandLineParser. May not be null.public final CommandLine getCommandLine()
Get the CommandLine, as previously parsed. (as_cmdLineParams, cmd_linePrsr)
must be called before this using this function.
public final PrintWriter getPrintWriter()
Get the PrintWriter, exactly as provided to the constructor.
public final int getWidth()
Get the width value, exactly as provided to the constructor.
public final String getCmdLineSyntax()
Get the command-line syntax string, exactly as provided to the constructor.
public final String getHeader()
Get the header string, exactly as provided to the constructor.
public final Options getOptions()
Get the Options, exactly as provided to the constructor.
public final int getLeftPad()
Get the left-pad value, exactly as provided to the constructor.
public final int getDescPad()
Get the description-pad value, exactly as provided to the constructor.
public final String getFooter()
Get the footer string, exactly as provided to the constructor.
public final boolean getAutoUsage()
Get the auto-usage value, exactly as provided to the constructor.
public final void crash()
Stop execution, and print out usage.
Equal to printHelp(null)
public final void crash(String s_error)
Stop execution, and print out usage. If an error message is provided, print it out, too (and first).
public final void printHelp()
Print out the usage string.
Equal to printHelp(null)
public final void printHelp(String s_error)
Print out the usage string, plus an optional error message.
Depending on the constructor signature use, that (similar) version of the [HelpFormatter].printHelp function is used.
s_error
- A specific error message, if appropriate. If null, then no specific error message is output. If non-null, then this is printed out immediately before the usage message.public final Outputter getOSDOOrOSDOAndFile(String s_optionName)
Get an Outputter to write to screen only, or both to screen and file.
getOSDOOrOSDOAndFile(s_optionName, true)
public final Outputter getOSDOOrOSDOAndFile(String s_optionName, boolean b_appendToFile)
Get an Outputter to write to screen only, or both to screen and file.
s_optionName
- The name of the parameter. If this parameter is provided, then it must have an argument, and that argument must be a legal (writeable and optionally existing) file name.getCommandLine().hasOption(s_optionName)
: new Outputter(new OWSDOAndFile(getCommandLine().getOptionValue(s_optionName), b_appendToFile))
new OSysDotOut()
public final int getInt(String s_optionName)
Get the int value of a parameter.
getInt(s_optionName, false, -1, (new RangeConfig()))
public final int getInt(String s_optionName, int i_defaultValue)
Get the int value of a parameter. If the parameter was not provided, use an alternate default value.
getInt(s_optionName, true, i_defaultValue, (new RangeConfig()))
public final int getInt(String s_optionName, RangeConfig range_config)
Get the int value of a parameter, which must conform to a range.
getInt(s_optionName, false, -1, range_config)
public final int getInt(String s_optionName, int i_defaultValue, RangeConfig range_config)
Get the int value of a parameter, which must conform to a range. If the parameter was not provided, use an alternate default value.
getInt(s_optionName, true, i_defaultValue, range_config)
public final int getInt(String s_optionName, boolean b_useDefaultValue, int i_defaultValue, RangeConfig range_config)
Get the int value of a parameter.
s_optionName
- The name of the desired parameter, which must have an argument. The value of the argument must be a legal int, acording to Integer.valueOf.b_useDefaultValue
- If true, then if the parameter was not provided on the command line, return i_defaultValue instead.i_defaultValue
- The default value to return, when the parameter is not provided. Ignored when b_useDefaultValue is false. Ignored when b_useDefaultValue is true, and this parameter was provided. When not ignored, must conform to range_config.isValid.range_config
- The range that the value must conform to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava