public abstract class BaseLauncher extends java.lang.Object implements ICLICommand
Constructor and Description |
---|
BaseLauncher(java.lang.String name,
java.io.PrintStream stdout,
java.io.PrintStream stderr,
IExitHandler exitHandler)
The constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addOption(org.apache.commons.cli.Option o) |
protected java.lang.String |
checkSubCommand(java.lang.String string) |
void |
displayHelp(org.apache.commons.cli.Options options,
java.io.PrintStream stdout,
java.io.PrintStream stderr)
Called to display the commands help
|
void |
doExit(int code)
This will exit the application
|
protected void |
fatal(java.lang.Exception e) |
protected void |
fatal(java.lang.String msg)
Called to issue a fatal message and exit
|
java.lang.String |
getName()
Used to get the command name
|
org.apache.commons.cli.Options |
getOptions()
Used to get the options of the command
|
protected java.io.PrintStream |
getStderr() |
protected java.io.PrintStream |
getStdout() |
protected void |
handleBadSubCommandOption(org.apache.commons.cli.Options options,
java.lang.String arg) |
protected void |
info(java.lang.String msg)
Called to issue a info message
|
void |
init(Controller controller)
Called to setup stuff that depends on the controller
|
void |
launch(java.lang.String[] args)
This should be called from the main method to launch the tool.
|
protected void |
printOptions(org.apache.commons.cli.Options options,
java.io.PrintStream stdout,
java.io.PrintStream stderr) |
protected void |
printUsage(org.apache.commons.cli.Options options,
java.io.PrintStream stdout,
java.io.PrintStream stderr) |
protected abstract boolean |
processOptionsInternal(java.lang.String[] args,
org.apache.commons.cli.CommandLine cmd) |
protected abstract boolean |
run()
This is executed to make the tool perform its function and should be extended.
|
protected boolean |
shouldDisplayHelp(java.lang.String[] args,
org.apache.commons.cli.CommandLine cmd,
java.lang.String subCommand) |
protected void |
warn(java.lang.String msg)
Called to issue a warning message
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getController
public BaseLauncher(java.lang.String name, java.io.PrintStream stdout, java.io.PrintStream stderr, IExitHandler exitHandler)
name
- The name of the commandstdout
- The standard output streamstderr
- The standard error streamexitHandler
- The exit handlerpublic void init(Controller controller)
controller
- The controllerpublic org.apache.commons.cli.Options getOptions()
protected void addOption(org.apache.commons.cli.Option o)
public void launch(java.lang.String[] args)
args
- The args passed from the CLIprotected void handleBadSubCommandOption(org.apache.commons.cli.Options options, java.lang.String arg)
protected boolean shouldDisplayHelp(java.lang.String[] args, org.apache.commons.cli.CommandLine cmd, java.lang.String subCommand)
protected java.lang.String checkSubCommand(java.lang.String string)
public void doExit(int code)
code
- The exit codeprotected void warn(java.lang.String msg)
msg
- The messageprotected void fatal(java.lang.String msg)
msg
- The messageprotected void fatal(java.lang.Exception e)
protected void info(java.lang.String msg)
msg
- The messagepublic java.lang.String getName()
getName
in interface ICLICommand
public void displayHelp(org.apache.commons.cli.Options options, java.io.PrintStream stdout, java.io.PrintStream stderr)
options
- The commands optionsstdout
- The standard output streamstderr
- The standard error streamprotected void printUsage(org.apache.commons.cli.Options options, java.io.PrintStream stdout, java.io.PrintStream stderr)
protected void printOptions(org.apache.commons.cli.Options options, java.io.PrintStream stdout, java.io.PrintStream stderr)
protected abstract boolean processOptionsInternal(java.lang.String[] args, org.apache.commons.cli.CommandLine cmd)
protected abstract boolean run()
protected java.io.PrintStream getStdout()
protected java.io.PrintStream getStderr()