Interface ArgumentReceiver

All Known Implementing Classes:
StandardOptions

public interface ArgumentReceiver
A command line argument receiver.

All non-positional arguments of a Command need a corresponding receiver to accept it through either testOption(String) or testParameter(String). If any receiver rejects a non-positional argument, the CLI will exit with an error.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Registers help information to the given HelpPrinter.
    default boolean
    Test if the given value-less option is accepted by the receiver.
    default Consumer<String>
    Test if the given parameter that requires a value is accepted by the receiver.
  • Method Details

    • testOption

      default boolean testOption(String name)
      Test if the given value-less option is accepted by the receiver.

      If the option is accepted, the receiver should store a stateful value to indicate the option was received, and the CLI will skip the argument for further processing.

      Parameters:
      name - Name of the option to test.
      Returns:
      Returns true if accepted.
    • testParameter

      default Consumer<String> testParameter(String name)
      Test if the given parameter that requires a value is accepted by the receiver.

      If the parameter is accepted, the receiver returns a Consumer that receives the expected value, and it should store a stateful value to allow the value to be later recalled. The CLI will skip the argument for further processing.

      Parameters:
      name - Name of the parameter to test.
      Returns:
      Returns a consumer if accepted or null if rejected.
    • registerHelp

      default void registerHelp(HelpPrinter printer)
      Registers help information to the given HelpPrinter.
      Parameters:
      printer - Printer to modify.