Package net.sourceforge.argparse4j.inf
Interface ArgumentAction
- All Known Implementing Classes:
AppendArgumentAction
,AppendConstArgumentAction
,CountArgumentAction
,HelpArgumentAction
,StoreArgumentAction
,StoreConstArgumentAction
,StoreFalseArgumentAction
,StoreTrueArgumentAction
,VersionArgumentAction
public interface ArgumentAction
This interface defines behavior of action when an argument is encountered at
the command line.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this action consumes argument.void
Called when ArgumentAction is added toArgument
usingArgument.action(ArgumentAction)
.void
Executes this action.
-
Method Details
-
run
void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) throws ArgumentParserExceptionExecutes 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 inArgumentParserException
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 ifarg
is an optional arguments.null
ifarg
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.
-
onAttach
Called when ArgumentAction is added toArgument
usingArgument.action(ArgumentAction)
.- Parameters:
arg
-Argument
object to which this object is added.
-
consumeArgument
boolean consumeArgument()Returnstrue
if this action consumes argument. Otherwise returnsfalse
.- Returns:
true
orfalse
.
-