public class JCommanderBasedMain extends Object implements ActionHelper
| Modifier and Type | Class and Description |
|---|---|
static class |
JCommanderBasedMain.MainParameters |
static class |
JCommanderBasedMain.MainParametersWithVersion |
static class |
JCommanderBasedMain.ProcessResult |
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Action> |
actions |
protected String[] |
arguments |
protected String |
command |
protected Runnable |
fullVersionInfoCallback |
protected PrintStream |
outputStream |
protected boolean |
printHelpOnError |
protected boolean |
printStackTrace |
protected Runnable |
shortVersionInfoCallback |
| Constructor and Description |
|---|
JCommanderBasedMain(String command,
Action... actions) |
| Modifier and Type | Method and Description |
|---|---|
String |
getCommandLineArguments() |
PrintStream |
getDefaultPrintStream() |
boolean |
isPrintStackTrace() |
JCommanderBasedMain.ProcessResult |
main(String... args) |
protected void |
printActionHelp(com.beust.jcommander.JCommander commander,
Action action) |
protected void |
printException(RuntimeException e,
com.beust.jcommander.JCommander commander,
Action action) |
protected void |
printGlobalHelp() |
protected void |
reg(Action a) |
void |
removeVersionInfoCallback()
Removes -v / --version option callbacks, and removes option by itself.
|
void |
setOutputStream(PrintStream outputStream) |
void |
setPrintStackTrace(boolean printStackTrace) |
void |
setVersionInfoCallback(Runnable versionInfoCallback)
Enables -v / --version parameter.
|
void |
setVersionInfoCallback(Runnable shortVersionInfoCallback,
Runnable fullVersionInfoCallback)
Enables -v / --version parameter.
|
protected final String command
protected boolean printHelpOnError
protected boolean printStackTrace
protected Runnable shortVersionInfoCallback
protected Runnable fullVersionInfoCallback
protected PrintStream outputStream
protected String[] arguments
public void setOutputStream(PrintStream outputStream)
public PrintStream getDefaultPrintStream()
getDefaultPrintStream in interface ActionHelperpublic String getCommandLineArguments()
getCommandLineArguments in interface ActionHelperpublic boolean isPrintStackTrace()
public void setPrintStackTrace(boolean printStackTrace)
protected void reg(Action a)
public JCommanderBasedMain.ProcessResult main(String... args) throws Exception
Exceptionprotected void printGlobalHelp()
protected void printActionHelp(com.beust.jcommander.JCommander commander,
Action action)
protected void printException(RuntimeException e, com.beust.jcommander.JCommander commander, Action action)
public void setVersionInfoCallback(Runnable versionInfoCallback)
versionInfoCallback - callback to be will be invoked if user specified -v optionpublic void setVersionInfoCallback(Runnable shortVersionInfoCallback, Runnable fullVersionInfoCallback)
shortVersionInfoCallback - callback to be will be invoked if user specified -v optionfullVersionInfoCallback - callback to be will be invoked if user specified --version optionpublic void removeVersionInfoCallback()
Copyright © 2018. All rights reserved.