Module net.sourceforge.argparse4j
Class HelpArgumentAction
java.lang.Object
net.sourceforge.argparse4j.impl.action.HelpArgumentAction
- All Implemented Interfaces:
ArgumentAction
Argument action to print help message and exit program.
Please note that this
run(ArgumentParser, Argument, Map, String, Object) always throws a
HelpScreenException exception after printing the help message.
consumeArgument() always returns false.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif this action consumes argument.voidCalled when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).voidExecutes this action.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sourceforge.argparse4j.inf.ArgumentAction
run
-
Constructor Details
-
HelpArgumentAction
public HelpArgumentAction()
-
-
Method Details
-
run
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) throws ArgumentParserExceptionDescription copied from interface:ArgumentActionExecutes this action.
If the objects derived from
RuntimeExceptionare thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserExceptionand give simple error message to explain what happened briefly.- Specified by:
runin interfaceArgumentAction- Parameters:
parser- The parser.arg- The argument this action attached to.attrs- Map to store attributes.flag- The actual option flag in command line ifargis a named arguments.nullifargis 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:ArgumentActionReturnstrueif this action consumes argument. Otherwise returnsfalse.- Specified by:
consumeArgumentin interfaceArgumentAction- Returns:
trueorfalse.
-
onAttach
Description copied from interface:ArgumentActionCalled when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).- Specified by:
onAttachin interfaceArgumentAction- Parameters:
arg-Argumentobject to which this object is added.
-