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

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void registerHelp​(HelpPrinter printer)
      Registers help information to the given HelpPrinter.
      default boolean testOption​(java.lang.String name)
      Test if the given value-less option is accepted by the receiver.
      default java.util.function.Consumer<java.lang.String> testParameter​(java.lang.String name)
      Test if the given parameter that requires a value is accepted by the receiver.
    • Method Detail

      • testOption

        default boolean testOption​(java.lang.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 java.util.function.Consumer<java.lang.String> testParameter​(java.lang.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.