public class CmdLineUtility extends Object
Constructor and Description |
---|
CmdLineUtility() |
Modifier and Type | Method and Description |
---|---|
static Set<CmdLineOption> |
check(CmdLineArgs cmdLineArgs)
Checks for required options which are not set and returns the ones it
finds.
|
void |
execute(CmdLineArgs cmdLineArgs)
Checks if required options are set and validation passes, then runs
handlers and executes its action.
|
CmdLineActionStore |
getActionStore() |
CmdLineOptionStore |
getOptionStore() |
CmdLinePresenter |
getPresenter() |
CmdLinePrinter |
getPrinter() |
static void |
handle(CmdLineArgs cmdLineArgs)
Runs the
CmdLineOptionHandler s for CmdLineArgs given. |
boolean |
handleHelp(CmdLineArgs cmdLineArgs)
Checks if help option was specified and if so prints out help.
|
boolean |
handlePrintSupportedActions(CmdLineArgs cmdLineArgs)
Checks if print supported actions option was specified and if so prints
out supported actions.
|
void |
initializeHandlers(Set<CmdLineOption> options)
Initializes each
CmdLineOptionHandler with their assigned
CmdLineOption . |
CmdLineArgs |
parse(String[] args)
Parses the given command line arguments and converts it to
CmdLineArgs . |
void |
printActionHelp(CmdLineArgs cmdLineArgs) |
void |
printActionMessages(List<String> messages) |
void |
printActionsHelp(CmdLineArgs cmdLineArgs) |
void |
printErrorMessage(String errorMessage) |
void |
printMissingRequiredOptionsError(Set<CmdLineOption> missingOptions) |
void |
printOptionHelp(CmdLineArgs cmdLineArgs) |
void |
printValidationErrors(List<CmdLineOptionValidator.Result> results) |
void |
run(String[] args)
Parses given command line arguments, then checks for help and print
supported actions options, prints them out if found, otherwise performs
execution on the arguments - see execute(CmdLineArgs).
|
void |
setActionStore(CmdLineActionStore actionStore) |
void |
setOptionStore(CmdLineOptionStore optionStore) |
void |
setPresenter(CmdLinePresenter presenter) |
void |
setPrinter(CmdLinePrinter printer) |
static List<CmdLineOptionValidator.Result> |
validate(CmdLineArgs cmdLineArgs)
Runs validation on
CmdLineArgs and returns the validation results. |
public CmdLineOptionStore getOptionStore()
public void setOptionStore(CmdLineOptionStore optionStore)
public CmdLineActionStore getActionStore()
public void setActionStore(CmdLineActionStore actionStore)
public CmdLinePrinter getPrinter()
public void setPrinter(CmdLinePrinter printer)
public CmdLinePresenter getPresenter()
public void setPresenter(CmdLinePresenter presenter)
public void printOptionHelp(CmdLineArgs cmdLineArgs)
public void printActionHelp(CmdLineArgs cmdLineArgs)
public void printActionsHelp(CmdLineArgs cmdLineArgs)
public void printValidationErrors(List<CmdLineOptionValidator.Result> results)
public void printMissingRequiredOptionsError(Set<CmdLineOption> missingOptions)
public void printErrorMessage(String errorMessage)
public void run(String[] args)
args
- The who will be parsed and executed.public CmdLineArgs parse(String[] args) throws CmdLineActionStoreException, CmdLineConstructionException
CmdLineArgs
.args
- The command line arguments to parse.CmdLineArgs
form.IOException
- On error parsing command line arguments.CmdLineConstructionException
- On error constructing command line arguments.CmdLineOptionStoreException
CmdLineActionStoreException
public void initializeHandlers(Set<CmdLineOption> options)
CmdLineOptionHandler
with their assigned
CmdLineOption
.options
- public boolean handleHelp(CmdLineArgs cmdLineArgs)
cmdLineArgs
- The CmdLineArgs
which will be checked for help optionpublic boolean handlePrintSupportedActions(CmdLineArgs cmdLineArgs)
cmdLineArgs
- The CmdLineArgs
which will be checked for print
supported action optionspublic void execute(CmdLineArgs cmdLineArgs) throws CmdLineActionExecutionException, CmdLineActionException
cmdLineArgs
- The CmdLineArgs
for which execution processing will be
run.CmdLineActionExecutionException
CmdLineActionException
public static Set<CmdLineOption> check(CmdLineArgs cmdLineArgs)
cmdLineArgs
- The CmdLineArgs
which will be check for required
options.CmdLineOption
s not specified.public static List<CmdLineOptionValidator.Result> validate(CmdLineArgs cmdLineArgs)
CmdLineArgs
and returns the validation results.cmdLineArgs
- The CmdLineArgs
which will be validated.CmdLineOptionValidator.Result
s generated when running
CmdLineOptionValidator
s.public static void handle(CmdLineArgs cmdLineArgs)
CmdLineOptionHandler
s for CmdLineArgs
given.cmdLineArgs
- The CmdLineArgs
whose option handlers will be run.Copyright © 1999–2017 Apache OODT. All rights reserved.