public static interface CommandLine.IExecutionStrategy
CommandLine.execute(String...)
method delegates to a configured execution strategy.
Implementation Requirements:
Implementers responsibilities are:
ParseResult
, select which CommandSpec
should be executed. This is especially important for commands that have subcommands.CommandSpec
. Often this means invoking a method on the spec's user object.setExecutionResult
to make the return value of that method invocation available to the applicationCommandLine.IExitCodeGenerator
.Implementors that need to print messages to the console should use the output and error PrintWriters, and the color scheme from the CommandLine object obtained from ParseResult's CommandSpec.
API Note:
This interface supersedes CommandLine.IParseResultHandler2
.
Modifier and Type | Method and Description |
---|---|
int |
execute(CommandLine.ParseResult parseResult)
"Executes" the user input and returns an exit code.
|
int execute(CommandLine.ParseResult parseResult) throws CommandLine.ExecutionException, CommandLine.ParameterException
setExecutionResult
.parseResult
- the parse result from which to select one or more CommandSpec
instances to execute.CommandLine.ParameterException
- if the invoked method on the CommandSpec's user object threw a ParameterException to signify invalid user input.CommandLine.ExecutionException
- if any problem occurred while executing the command. Any exceptions (other than ParameterException) should be wrapped in a ExecutionException and not thrown as is.