java.io.Closeable
, java.lang.AutoCloseable
MultiCommand
public abstract class Command
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field | Description |
---|---|---|
protected java.lang.String |
description |
A description of the command, used in the help output.
|
protected joptsimple.OptionParser |
parser |
The option parser for this command.
|
Constructor | Description |
---|---|
Command(java.lang.String description,
java.lang.Runnable beforeMain) |
Construct the command with the specified command description and runnable to execute before main is invoked.
|
Modifier and Type | Method | Description |
---|---|---|
protected boolean |
addShutdownHook() |
Return whether or not to install the shutdown hook to cleanup resources on exit.
|
void |
close() |
|
protected abstract void |
execute(Terminal terminal,
joptsimple.OptionSet options) |
Executes this command.
|
protected static void |
exit(int status) |
|
int |
main(java.lang.String[] args,
Terminal terminal) |
Parses options for this command from args and executes it.
|
protected void |
printAdditionalHelp(Terminal terminal) |
Prints additional help information, specific to the command
|
protected final java.lang.String description
protected final joptsimple.OptionParser parser
public Command(java.lang.String description, java.lang.Runnable beforeMain)
description
- the command descriptionbeforeMain
- the before-main runnablepublic final int main(java.lang.String[] args, Terminal terminal) throws java.lang.Exception
java.lang.Exception
protected void printAdditionalHelp(Terminal terminal)
protected static void exit(int status)
protected abstract void execute(Terminal terminal, joptsimple.OptionSet options) throws java.lang.Exception
UserException
.java.lang.Exception
protected boolean addShutdownHook()
public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException