public class SimpleJSAP extends JSAP
JSAP
that handles directly help,
explanation and an array of parameters.
More precisely, instances of this class behave exactly like those of
JSAP
, but additionally require a command name, an explanation
(a wordy description) and an array of parameters (which will be registered automatically).
A switch activated by --help is always
registered under the ID help.
A message will be automatically printed upon invocation
of the parse()
methods if an error occurs, or if the help switch is detected. In this
case, messagePrinted()
will return true, and the caller may check this condition
to stop its actions.
The screen width used to format the help text may be set using setScreenWidth(int)
.
The formatter will preserve newlines.
Note: as of 2.0a non-breaking spaces are temporarily disabled until some console encoding
issues have been worked out. - ML
BIGDECIMAL_PARSER, BIGINTEGER_PARSER, BOOLEAN_PARSER, BYTE_PARSER, CHARACTER_PARSER, CLASS_PARSER, COLOR_PARSER, DEFAULT_LISTSEPARATOR, DEFAULT_PARAM_HELP_SEPARATOR, DEFAULT_SCREENWIDTH, DOUBLE_PARSER, FLOAT_PARSER, GREEDY, INETADDRESS_PARSER, INTEGER_PARSER, INTSIZE_PARSER, LIST, LONG_PARSER, LONGSIZE_PARSER, MULTIPLEDECLARATIONS, NO_DEFAULT, NO_HELP, NO_LONGFLAG, NO_MULTIPLEDECLARATIONS, NO_SHORTFLAG, NOT_GREEDY, NOT_LIST, NOT_REQUIRED, PACKAGE_PARSER, REQUIRED, SHORT_PARSER, STRING_PARSER, URL_PARSER
Constructor and Description |
---|
SimpleJSAP(String name)
Creates a new simple JSAP with a help switch, no explanation and default screen width.
|
SimpleJSAP(String name,
String explanation)
Creates a new simple JSAP with default screen width.
|
SimpleJSAP(String name,
String explanation,
Parameter[] parameter)
Creates a new simple JSAP with default screen width.
|
Modifier and Type | Method and Description |
---|---|
int |
getScreenWidth()
Returns the current screen width.
|
boolean |
messagePrinted()
Returns true if the last parsing caused the a message to be printed.
|
JSAPResult |
parse(String arg)
Parses the specified command line.
|
JSAPResult |
parse(String[] arg)
Parses the specified command line array.
|
SimpleJSAP |
setScreenWidth(int screenWidth)
Sets the screen width.
|
finalize, getByID, getByLongFlag, getByShortFlag, getByShortFlag, getDefaults, getHelp, getHelp, getHelp, getIDMap, getUnflaggedOptionsIterator, getUsage, registerDefaultSource, registerParameter, setHelp, setUsage, toString, unregisterDefaultSource, unregisterParameter
public SimpleJSAP(String name, String explanation, Parameter[] parameter) throws JSAPException
name
- the name of the command for which help will be printed.explanation
- a wordy explanation of the command, or null
for no explanation.parameter
- an array of parameters, which will be registered for you, or null
.JSAPException
public SimpleJSAP(String name, String explanation) throws JSAPException
name
- the name of the command for which help will be printed.explanation
- a wordy explanation of the command, or null
for no explanation.JSAPException
public SimpleJSAP(String name) throws JSAPException
name
- the name of the command for which help will be printed.JSAPException
public JSAPResult parse(String arg)
JSAP
public JSAPResult parse(String[] arg)
JSAP
public int getScreenWidth()
This value will be passed to JSAP.getHelp(int)
, and used
to format the explanation.
public SimpleJSAP setScreenWidth(int screenWidth)
screenWidth
- the new screen width.public boolean messagePrinted()
Copyright © 2016. All rights reserved.