|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.trendmicro.grid.acl.client.util.CommandlineParser
public class CommandlineParser
Simple helper class to simplify building commandline apps.
Constructor Summary | |
---|---|
CommandlineParser()
Constructs a new instance of CommandlineParser. |
Method Summary | ||
---|---|---|
CommandlineParser |
defineParameter(String description,
boolean required,
Class type,
Object defaultValue,
String... names)
Defines a parameter inside the commandline interface. |
|
CommandlineParser |
defineSwitchParameter(String description,
String... names)
Defines a switch (boolean) parameter. |
|
Object |
getParameter(String name)
Returns the first parameter value of the declared non-switch parameter. |
|
|
getParameter(String name,
Class<T> type)
Returns the first parameter value of the declared non-switch parameter. |
|
Object[] |
getParameterValues(String name)
Returns all parameter values of the declared non-switch parameter. |
|
|
getParameterValues(String name,
Class<T> type)
Returns all parameter values of the declared non-switch parameter. |
|
boolean |
isParameterTrue(String name)
Returns true if the declared switch parameter was set. |
|
static String[] |
loadHelp(URL helpURL)
Loads the additional CLI help content from the given URL and returns it. |
|
boolean |
parse(String[] args,
PrintStream out,
String[] help)
Parses the given commandline args and returns true if the application can continue to run. |
|
boolean |
parse(String[] args,
PrintStream out,
URL help)
Parses the given commandline args and returns true if the application can continue to run. |
|
void |
printHelp(PrintStream out)
Prints a command line help to out using the parameter definitions as input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommandlineParser()
Method Detail |
---|
public static String[] loadHelp(URL helpURL)
helpURL
- the URL to load the additional commandline help from.
public CommandlineParser defineSwitchParameter(String description, String... names)
description
- the human readable description used inside the commandline help.names
- the parameter interface names including prefix.
public CommandlineParser defineParameter(String description, boolean required, Class type, Object defaultValue, String... names)
description
- the human readable description used inside the commandline help.required
- whether the parameter must be specified or not.type
- the type to convert the parameters, raw value to (e.g. File, Integer, URI, etc).defaultValue
- The default value to apply when the parameter was not set.names
- the parameter interface names including prefix.
public boolean parse(String[] args, PrintStream out, URL help)
args
- the list of commandline args.out
- the stream to write any output to.help
- the lines of help content excluding the application greeting message.
public boolean parse(String[] args, PrintStream out, String[] help)
args
- the list of commandline args.out
- the stream to write any output to.help
- the lines of help content excluding the application greeting message.
public boolean isParameterTrue(String name)
name
- the name of the declared parameter.
public <T> T getParameter(String name, Class<T> type)
name
- the name of the declared parameter.type
- the type of the parameter to return.
public Object getParameter(String name)
name
- the name of the declared parameter.
public <T> List<T> getParameterValues(String name, Class<T> type)
name
- the name of the declared parameter.type
- the type of the parameter to return.
public Object[] getParameterValues(String name)
name
- the name of the declared parameter.
public void printHelp(PrintStream out)
out
- The print stream to write the commandline help to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |