Interface CommandLine.IExecutionStrategy

All Known Implementing Classes:
CommandLine.AbstractParseResultHandler, CommandLine.RunAll, CommandLine.RunFirst, CommandLine.RunLast
Enclosing class:
CommandLine

public static interface CommandLine.IExecutionStrategy

Implementations are responsible for "executing" the user input and returning an exit code. The CommandLine.execute(String...) method delegates to a configured execution strategy.

Implementation Requirements:

Implementers responsibilities are:

  • From the ParseResult, select which CommandSpec should 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.
  • Call setExecutionResult to 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 CommandLine.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.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    "Executes" the user input and returns an exit code.