Package io.github.qishr.cascara.common.util
Class RunAll
java.lang.Object
io.github.qishr.cascara.common.util.CommandLine.AbstractHandler<java.util.List<java.lang.Object>
io.github.qishr.cascara.common.util.CommandLine.AbstractParseResultHandler<java.util.List<java.lang.Object>
io.github.qishr.cascara.common.util.CommandLine.RunAll
All Implemented Interfaces:
IParseResultHandler
Enclosing Class:
io.github.qishr.cascara.common.util.CommandLine
public static class RunAll
extends io.github.qishr.cascara.common.util.CommandLine.AbstractParseResultHandler<java.util.List<Object>
Command line IExecutionStrategy that prints help if requested, and otherwise executes the top-level command and
all subcommands as Runnable, Callable or Method.For use by the execute method.
Constructor Summary
| Constructor | Description |
|---|---|
| RunAll() |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public int | execute(ParseResult parseResult) | |
| public List<Object> | handleParseResult(List<CommandLine> parsedCommands, PrintStream out, Ansi ansi) | Prints help if requested, and otherwise executes the top-level command and all subcommands as Runnable, Callable or Method. |
| protected List<Object> | handle(ParseResult parseResult) | Executes the top-level command and all subcommands as Runnable or Callable. |
| protected List<IExitCodeGenerator> | extractExitCodeGenerators(ParseResult parseResult) | |
| protected RunAll | self() |
Method Details
execute
public int execute(ParseResult parseResult)
Throws:
handleParseResult
public List<Object> handleParseResult(List<CommandLine> parsedCommands, PrintStream out, Ansi ansi)
Prints help if requested, and otherwise executes the top-level command and all subcommands as Runnable,
Callable or Method.Finally, either a list of result objects is returned, or the JVM is terminated if an exit
code was set. If any of the CommandLine commands does not implement either
Runnable or Callable, an ExecutionException
is thrown detailing the problem and capturing the offending CommandLine object.
Parameters:
parsedCommands - the CommandLine objects that resulted from successfully parsing the command line arguments
out - the PrintStream to print help to if requested
ansi - for printing help messages using ANSI styles and colors
Returns:
an empty list if help was requested, or a list containing the result of executing all commands:
the return values from calling the Callable commands, null elements for commands that implement Runnable
Specified By:
handle
protected List<Object> handle(ParseResult parseResult)
Executes the top-level command and all subcommands as Runnable or Callable.If any of the CommandLine commands does not implement either Runnable or Callable and is not a Method, an ExecutionException
is thrown detailing the problem and capturing the offending CommandLine object.
Parameters:
parseResult - the ParseResult that resulted from successfully parsing the command line arguments
Returns:
an empty list if help was requested, or a list containing the result of executing all commands:
the return values from calling the Callable commands, null elements for commands that implement Runnable
Throws:
Since:
3.0
extractExitCodeGenerators
protected List<IExitCodeGenerator> extractExitCodeGenerators(ParseResult parseResult)
self
protected RunAll self()
Overrides: