CommandLine.RunFirst (picocli 3.9.6 API)
Date: 2019-04-06

picocli

## Class CommandLine.RunFirst

- java.lang.Object
- - picocli.CommandLine.AbstractHandler<R,CommandLine.AbstractParseResultHandler<R>>
  - - picocli.CommandLine.AbstractParseResultHandler<java.util.List<java.lang.Object>>
    - - picocli.CommandLine.RunFirst

- All Implemented Interfaces:
    CommandLine.IParseResultHandler, CommandLine.IParseResultHandler2<java.util.List<java.lang.Object>>
  Enclosing class:
    CommandLine

      public static class CommandLine.RunFirst
      extends CommandLine.AbstractParseResultHandler<java.util.List<java.lang.Object>>
      implements CommandLine.IParseResultHandler

  Command line parse result handler that prints help if requested, and otherwise executes the top-level `Runnable` or `Callable` command. For use in the `parseWithHandler` methods.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RunFirst()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.util.List<java.lang.Object>` | `handle(CommandLine.ParseResult parseResult)` Executes the top-level `Runnable` or `Callable` subcommand.
    `java.util.List<java.lang.Object>` | `handleParseResult(java.util.List<CommandLine> parsedCommands, java.io.PrintStream out, CommandLine.Help.Ansi ansi)` Prints help if requested, and otherwise executes the top-level `Runnable` or `Callable` command.
    `protected CommandLine.RunFirst` | `self()` Returns `this` to allow method chaining when calling the setters for a fluent API.

    - ### Methods inherited from class picocli.CommandLine.AbstractParseResultHandler

      `handleParseResult`

    - ### Methods inherited from class picocli.CommandLine.AbstractHandler

      `andExit, ansi, err, exit, exitCode, hasExitCode, out, returnResultOrExit, throwOrExit, useAnsi, useErr, useOut`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RunFirst

          public RunFirst()

  - ### Method Detail

    - #### handleParseResult

          public java.util.List<java.lang.Object> handleParseResult(java.util.List<CommandLine> parsedCommands,
                                                                    java.io.PrintStream out,
                                                                    CommandLine.Help.Ansi ansi)

      Prints help if requested, and otherwise executes the top-level `Runnable` or `Callable` command. Finally, either a list of result objects is returned, or the JVM is terminated if an exit code was set. If the top-level command does not implement either `Runnable` or `Callable`, an `ExecutionException` is thrown detailing the problem and capturing the offending `CommandLine` object.
      Specified by:
        `handleParseResult` in interface `CommandLine.IParseResultHandler`
      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 a single element: the result of calling the `Callable`, or a `null` element if the top-level command was a `Runnable`
      Throws:
        `CommandLine.ParameterException` - if the `HelpCommand` was invoked for an unknown subcommand. Any `ParameterExceptions` thrown from this method are treated as if this exception was thrown during parsing and passed to the `CommandLine.IExceptionHandler`
        `CommandLine.ExecutionException` - if a problem occurred while processing the parse results; use `CommandLine.ExecutionException.getCommandLine()` to get the command or subcommand where processing failed

    - #### handle

          protected java.util.List<java.lang.Object> handle(CommandLine.ParseResult parseResult)
                                                     throws CommandLine.ExecutionException

      Executes the top-level `Runnable` or `Callable` subcommand. If the top-level command does not implement either `Runnable` or `Callable`, an `ExecutionException` is thrown detailing the problem and capturing the offending `CommandLine` object.
      Specified by:
        `handle` in class `CommandLine.AbstractParseResultHandler<java.util.List<java.lang.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 a single element: the result of calling the `Callable`, or a `null` element if the last (sub)command was a `Runnable`
      Throws:
        `CommandLine.ExecutionException` - if a problem occurred while processing the parse results; use `CommandLine.ExecutionException.getCommandLine()` to get the command or subcommand where processing failed
      Since:
        3.0

    - #### self

          protected CommandLine.RunFirst self()

      Description copied from class: `CommandLine.AbstractHandler`
      Returns `this` to allow method chaining when calling the setters for a fluent API.
      Specified by:
        `self` in class `CommandLine.AbstractHandler<java.util.List<java.lang.Object>,CommandLine.AbstractParseResultHandler<java.util.List<java.lang.Object>>>`