Interface ArgumentAction

    • Method Detail

      • run

        @Deprecated
        void run​(ArgumentParser parser,
                 Argument arg,
                 java.util.Map<java.lang.String,​java.lang.Object> attrs,
                 java.lang.String flag,
                 java.lang.Object value)
          throws ArgumentParserException
        Deprecated.
        Does not provide the flexibility to let the parser and/or argument decide how the value is stored. run(ArgumentParser, Argument, Map, String, Object, Consumer) will be called instead. Existing actions should implement that method.

        Executes this action.

        If the objects derived from RuntimeException are thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them in ArgumentParserException and give simple error message to explain what happened briefly.

        Parameters:
        parser - The parser.
        arg - The argument this action attached to.
        attrs - Map to store attributes.
        flag - The actual option flag in command line if arg is a named arguments. null if arg is a positional argument.
        value - The attribute value. This may be null if this action does not consume any arguments.
        Throws:
        ArgumentParserException - If error occurred.
      • run

        default void run​(ArgumentParser parser,
                         Argument arg,
                         java.util.Map<java.lang.String,​java.lang.Object> attrs,
                         java.lang.String flag,
                         java.lang.Object value,
                         java.util.function.Consumer<java.lang.Object> valueSetter)
                  throws ArgumentParserException

        Executes this action.

        If the objects derived from RuntimeException are thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them in ArgumentParserException and give simple error message to explain what happened briefly.

        Parameters:
        parser - The parser.
        arg - The argument this action attached to.
        attrs - The current map of attributes. Implementations may read from this map, but may not change it. Implementations must call the valueSetter with the actual value to be set.
        flag - The actual option flag in command line if arg is a named arguments. null if arg is a positional argument.
        value - The attribute value. This may be null if this action does not consume any arguments.
        valueSetter - The consumer that will set the actual value determined by this action in the result.
        Throws:
        ArgumentParserException - If error occurred.
      • consumeArgument

        boolean consumeArgument()
        Returns true if this action consumes argument. Otherwise returns false.
        Returns:
        true or false.