Class CommandLine.RunFirst

java.lang.Object
org.apache.logging.log4j.core.tools.picocli.CommandLine.RunFirst
All Implemented Interfaces:
CommandLine.IParseResultHandler
Enclosing class:
CommandLine

public static class CommandLine.RunFirst extends 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.

From picocli v2.0, RunFirst is used to implement the run and call convenience methods.

Since:
2.0
  • Constructor Details

    • RunFirst

      public RunFirst()
  • Method Details

    • handleParseResult

      public List<Object> handleParseResult(List<CommandLine> parsedCommands, PrintStream out, CommandLine.Help.Ansi ansi)
      Prints help if requested, and otherwise executes the top-level Runnable or Callable command. If the top-level command does not implement either Runnable or Callable, a 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.ExecutionException - if a problem occurred while processing the parse results; use CommandLine.ExecutionException.getCommandLine() to get the command or subcommand where processing failed