- All Known Implementing Classes:
- Enclosing class:
public static interface CommandLine.IExecutionStrategyImplementations are responsible for "executing" the user input and returning an exit code. The
CommandLine.execute(String...)method delegates to a configured execution strategy.
Implementers responsibilities are:
- From the
ParseResult, select which
CommandSpecshould be executed. This is especially important for commands that have subcommands.
- "Execute" the selected
CommandSpec. Often this means invoking a method on the spec's user object.
setExecutionResultto make the return value of that method invocation available to the application
- Return an exit code. Common sources of exit values are the invoked method's return value, or the user object if it implements
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.
This interface supersedes
All Methods Instance Methods Abstract Methods Modifier and Type Method Description
execute(CommandLine.ParseResult parseResult)"Executes" the user input and returns an exit code.
int execute(CommandLine.ParseResult parseResult) throws CommandLine.ExecutionException, CommandLine.ParameterException"Executes" the user input and returns an exit code. Execution often means invoking a method on the selected CommandSpec's user object, and making the return value of that invocation available via
parseResult- the parse result from which to select one or more
CommandSpecinstances to execute.
- an exit code
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.