|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.globus.gridshib.common.cli.BaseCLI
public abstract class BaseCLI
A basic command-line interface with common options used by all GridShib tools and clients. This abstract class should be extended by a concrete CLI implementation that may add command-line options of its own.
The subclass must fulfill the following contract:
BaseCLI(String[]) constructor must be invokedparse() method must be calleddisplayUsage() method must be implementedBaseLogging interface
must be implementedrun() method of the
Testable interface must
be implementedNote: Some members of this class go all the way back to GridShib SAML Tools v0.1.0. See the User Guide for details.
BaseLogging,
Testable| Field Summary | |
|---|---|
protected static org.apache.commons.cli.Option |
DEBUG
The --debug option. |
protected static org.apache.commons.cli.Option |
HELP
The --help option. |
protected static org.apache.commons.cli.Option |
INPUT
The --infile option. |
protected static String |
INPUT_DESCRIPTION
Description of the --infile option. |
protected static org.apache.commons.cli.Option |
OUTPUT
The --outfile option. |
protected static String |
OUTPUT_DESCRIPTION
Description of the --outfile option. |
protected static org.apache.commons.cli.Option |
QUIET
The --quiet option. |
| Fields inherited from interface org.globus.gridshib.common.cli.Testable |
|---|
APPLICATION_ERROR, COMMAND_LINE_ERROR, CONFIG_FILE_ERROR, SECURITY_ERROR, SUCCESS_CODE |
| Constructor Summary | |
|---|---|
protected |
BaseCLI(String[] args)
A subclass MUST invoke this constructor. |
| Method Summary | |
|---|---|
protected abstract void |
displayUsage()
A concrete subclass MUST implement this method. |
String[] |
getArgs()
Gets the command-line arguments used to invoke the application. |
org.apache.commons.cli.CommandLine |
getCommandLine()
|
int |
getExitCode()
If this method is called before calling the setExitCode(int) method, this
method returns Testable.SECURITY_ERROR. |
int |
getExitCode(boolean forceRun)
This method is equivalent to |
protected File |
getInfile()
Deprecated. as of 0.5.0, use getInputPath() instead |
protected String |
getInputPath()
|
protected org.apache.commons.cli.Options |
getOptions()
|
protected File |
getOutfile()
Deprecated. as of 0.5.0, use getOutputPath() instead |
protected String |
getOutputPath()
|
protected boolean |
isDebug()
|
protected void |
parse()
A subclass MUST call this method. |
abstract void |
run()
Execute the command-line application. |
void |
setExitCode(int exitCode)
Sets the exit code of the application. |
protected void |
validate()
If a subclass adds its own command-line options, this method will most likely be overridden. |
protected boolean |
wantQuiet()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.globus.gridshib.common.BaseLogging |
|---|
configureLogger, getLogConfigPath, setDebugLogLevel |
| Field Detail |
|---|
protected static String INPUT_DESCRIPTION
--infile option.
protected static String OUTPUT_DESCRIPTION
--outfile option.
protected static org.apache.commons.cli.Option INPUT
--infile option.
This option was introduced in GS-ST v0.3.0.
protected static org.apache.commons.cli.Option OUTPUT
--outfile option.
This option was introduced in GS-ST v0.1.0.
protected static org.apache.commons.cli.Option DEBUG
--debug option.
This option was introduced in GS-ST v0.1.0.
protected static org.apache.commons.cli.Option QUIET
--quiet option.
This option was introduced in GS-ST v0.1.0.
protected static org.apache.commons.cli.Option HELP
--help option.
This option was introduced in GS-ST v0.1.0.
| Constructor Detail |
|---|
protected BaseCLI(String[] args)
args - an array of command-line arguments| Method Detail |
|---|
protected String getInputPath()
protected String getOutputPath()
protected boolean isDebug()
protected boolean wantQuiet()
protected File getInfile()
getInputPath() instead
protected File getOutfile()
getOutputPath() instead
protected org.apache.commons.cli.Options getOptions()
public org.apache.commons.cli.CommandLine getCommandLine()
public String[] getArgs()
Testable
getArgs in interface Testable
public abstract void run()
throws ApplicationRuntimeException
TestableTestable.setExitCode(int) but
MUST NOT call System.exit(int).
run in interface TestableApplicationRuntimeException - if execution of the application failspublic int getExitCode()
setExitCode(int) method, this
method returns Testable.SECURITY_ERROR.
This helps prevent unintended exit codes.
getExitCode in interface Testablepublic int getExitCode(boolean forceRun)
this.run(); int exitCode = this.getExitCode();If the
run() method throws an exception, this
method logs an error message and returns the exit
code. For this reason, this method is mainly useful
in unit tests.
getExitCode in interface Testablepublic void setExitCode(int exitCode)
Testable
setExitCode in interface TestableexitCode - the exit code
protected final void parse()
throws Exception
Exception - If command-line parsing fails
protected void validate()
throws Exception
Exception - If validation failsprotected abstract void displayUsage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||