public class FlagWithArgument extends java.lang.Object implements CommandlineFragment
A fragment that represents a flag with an argument, e.g., --foo bar.
COMMAND_PREFIX| Constructor and Description |
|---|
FlagWithArgument(java.lang.String name,
java.lang.String argName,
java.lang.String description,
boolean optional)
Construct a new fragment holder.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String> |
consume(java.util.List<java.lang.String> s)
Grab the pieces of the commandline relevant to this argument, configure the
implementation, and then return a new array of arguments that will have the
pieces of the original commandline that this command used removed.
|
java.lang.String |
getDescription()
Return a description of this commandline fragment.
|
java.lang.String |
getUsage()
Construct a usage string for this commandline fragment.
|
java.lang.String |
getValue() |
boolean |
isOptional() |
boolean |
isSet() |
void |
reset()
Reset the fragment to its initial state.
|
void |
setOptional(boolean o) |
boolean |
validate() |
public FlagWithArgument(java.lang.String name,
java.lang.String argName,
java.lang.String description,
boolean optional)
name - the name of the flag, as it will be used on the commandlineargName - the name of the argument, as it will be used to generate usage and helpdescription - the description of the flagoptional - whether or not this flag is optionalpublic boolean isOptional()
isOptional in interface CommandlineFragmenttrue if this fragment is optional.public void setOptional(boolean o)
public java.util.List<java.lang.String> consume(java.util.List<java.lang.String> s)
throws CommandlineSyntaxException
CommandlineFragmentGrab the pieces of the commandline relevant to this argument, configure the implementation, and then return a new array of arguments that will have the pieces of the original commandline that this command used removed.
consume in interface CommandlineFragments - the list of argumentsCommandlineSyntaxException - if the commandline is structurally invalid.public void reset()
CommandlineFragmentReset the fragment to its initial state. This is useful for reusing fragments in multiple commandline structures.
reset in interface CommandlineFragmentpublic boolean isSet()
public java.lang.String getValue()
public java.lang.String getUsage()
CommandlineFragmentConstruct a usage string for this commandline fragment. The usage string is used when constructing a strawman commandline example and when formatting help.
getUsage in interface CommandlineFragmentpublic java.lang.String getDescription()
CommandlineFragmentReturn a description of this commandline fragment. The description should be a (short) narrative item that describes the purpose of the fragment. It is only used when formatting help.
getDescription in interface CommandlineFragmentpublic boolean validate()