public abstract class BaseTool extends java.lang.Object implements CLITool
CLIToolOptions
objects to be used for modular options processing.| Modifier | Constructor and Description |
|---|---|
protected |
BaseTool() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToolOptions(CLIToolOptions option)
Add a new CLIToolOptions object to the options used by this tool.
|
void |
exit(int exitcode)
Calls the exit method
|
protected org.apache.commons.cli.CommandLine |
getCommandLine() |
abstract java.lang.String |
getHelpString() |
protected org.apache.commons.cli.Options |
getOptions() |
protected abstract void |
go()
Perform the actions for the tool
|
void |
help()
Writes help message .
|
protected void |
initOptions()
initialize any options, will apply this for each CLIToolOptions added to the tool.
|
protected abstract boolean |
isUseHelpOption() |
protected java.lang.String |
optionDisplayString(java.lang.String opt)
Return a string to display the specified option in help text
|
protected java.lang.String |
optionDisplayString(java.lang.String opt,
boolean extended)
Return a string to display the specified option in help text
|
org.apache.commons.cli.CommandLine |
parseArgs(java.lang.String[] args)
Parse the options, will apply this for each CLIToolOptions added to the tool.
|
void |
run(java.lang.String[] args)
Run the tool's lifecycle given the input arguments.
|
protected void |
setShouldExit(boolean shouldExit)
Set whether the
exit(int) method should call System.exit. |
void |
validateOptions(org.apache.commons.cli.CommandLine cli,
java.lang.String[] args)
Validate the values parsed by the options, will apply this for each CLIToolOptions added to the tool.
|
protected void addToolOptions(CLIToolOptions option)
option - optionsprotected abstract boolean isUseHelpOption()
protected void initOptions()
protected org.apache.commons.cli.Options getOptions()
protected java.lang.String optionDisplayString(java.lang.String opt)
opt - opt nameprotected java.lang.String optionDisplayString(java.lang.String opt,
boolean extended)
extended - if true, include full argument descriptoropt - opt namepublic void run(java.lang.String[] args)
throws CLIToolException
run in interface CLIToolargs - the cli arg vectorCLIToolException - if an error occurspublic org.apache.commons.cli.CommandLine parseArgs(java.lang.String[] args)
throws CLIToolOptionsException
parseArgs in interface CLIToolargs - the cli arg vectorCLIToolOptionsException - parse errorpublic void validateOptions(org.apache.commons.cli.CommandLine cli,
java.lang.String[] args)
throws CLIToolOptionsException
cli - cliargs - argsCLIToolOptionsException - if an error occursprotected abstract void go()
throws CLIToolException
CLIToolException - on errorprotected org.apache.commons.cli.CommandLine getCommandLine()
public abstract java.lang.String getHelpString()
public void exit(int exitcode)
protected void setShouldExit(boolean shouldExit)
exit(int) method should call System.exit.shouldExit - true to exit