Package net.sourceforge.argparse4j.inf
Interface ArgumentAction
-
- All Known Implementing Classes:
AppendArgumentAction,AppendConstArgumentAction,CountArgumentAction,HelpArgumentAction,StoreArgumentAction,StoreConstArgumentAction,StoreFalseArgumentAction,StoreTrueArgumentAction,VersionArgumentAction
public interface ArgumentActionThis interface defines behavior of action when an argument is encountered at the command line.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanconsumeArgument()Returnstrueif this action consumes argument.voidonAttach(Argument arg)Called when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).voidrun(ArgumentParser parser, Argument arg, java.util.Map<java.lang.String,java.lang.Object> attrs, java.lang.String flag, java.lang.Object value)Executes this action.
-
-
-
Method Detail
-
run
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
Executes 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.- 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 an optional 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.
-
onAttach
void onAttach(Argument arg)
Called when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).- Parameters:
arg-Argumentobject to which this object is added.
-
consumeArgument
boolean consumeArgument()
Returnstrueif this action consumes argument. Otherwise returnsfalse.- Returns:
trueorfalse.
-
-