Class VersionArgumentAction

java.lang.Object
net.sourceforge.argparse4j.impl.action.VersionArgumentAction
All Implemented Interfaces:
ArgumentAction

public class VersionArgumentAction extends Object implements ArgumentAction

Argument action to print version message and exit program.

Please note that this run(ArgumentParser, Argument, Map, String, Object) terminates program after printing the version message. consumeArgument() always returns false.

  • Constructor Details

    • VersionArgumentAction

      public VersionArgumentAction()
  • Method Details

    • run

      public void run(ArgumentParser parser, Argument arg, Map<String,Object> attrs, String flag, Object value)
      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 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.
    • 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.
    • onAttach

      public void onAttach(Argument arg)
      Description copied from interface: ArgumentAction
      Called when ArgumentAction is added to Argument using Argument.action(ArgumentAction).
      Specified by:
      onAttach in interface ArgumentAction
      Parameters:
      arg - Argument object to which this object is added.