Class AppendArgumentAction

  • All Implemented Interfaces:
    ArgumentAction

    public class AppendArgumentAction
    extends java.lang.Object
    implements ArgumentAction

    Argument action to store a list.

    This action appends each argument value to the list. The list is of type List. This is useful to allow an option to be specified multiple times. If attrs contains non-List object for key Argument.getDest(), it will be overwritten by the List containing value. consumeArgument() always returns true.

    • Constructor Detail

      • AppendArgumentAction

        public AppendArgumentAction()
    • Method Detail

      • run

        public 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
        Description copied from interface: ArgumentAction

        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.

        Specified by:
        run in interface ArgumentAction
        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 an optional 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.
      • consumeArgument

        public boolean consumeArgument()
        Description copied from interface: ArgumentAction
        Returns true if this action consumes argument. Otherwise returns false.
        Specified by:
        consumeArgument in interface ArgumentAction
        Returns:
        true or false.