Package com.android.sdklib.util
Class CommandLineParser.Arg
- java.lang.Object
-
- com.android.sdklib.util.CommandLineParser.Arg
-
- Enclosing class:
- CommandLineParser
protected static class CommandLineParser.Arg extends java.lang.ObjectAn argument accepted by the command-line, also called "a flag". Arguments must have a short version (one letter), a long version name and a description. They can have a default value, or it can be null. Depending on theCommandLineParser.Mode, the default value can be a Boolean, an Integer, a String or a String array (in which case the first item is the current by default.)
-
-
Constructor Summary
Constructors Constructor Description Arg(CommandLineParser.Mode mode, boolean mandatory, java.lang.String verb, java.lang.String directObject, java.lang.String shortName, java.lang.String longName, java.lang.String description, java.lang.Object defaultValue)Creates a new argument flag description.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetCurrentValue()Returns the current value.java.lang.ObjectgetDefaultValue()Returns the default value.java.lang.StringgetDescription()Returns the description.java.lang.StringgetDirectObject()Returns the direct Object for that argument.java.lang.StringgetLongArg()Returns the long name of the argument, e.g.CommandLineParser.ModegetMode()Returns the argument mode (type + process method).java.lang.StringgetShortArg()Returns the 1-letter short name of the argument, e.g.java.lang.StringgetVerb()Returns the verb for that argument.booleanisInCommandLine()Returns true if the argument has been used on the command line.booleanisMandatory()Return true if this argument is mandatory for this verb/directobject.voidsetCurrentValue(java.lang.Object currentValue)Sets the current value.voidsetInCommandLine(boolean inCommandLine)Sets if the argument has been used on the command line.
-
-
-
Constructor Detail
-
Arg
public Arg(CommandLineParser.Mode mode, boolean mandatory, @NonNull java.lang.String verb, @NonNull java.lang.String directObject, @NonNull java.lang.String shortName, @NonNull java.lang.String longName, @NonNull java.lang.String description, @Nullable java.lang.Object defaultValue)
Creates a new argument flag description.- Parameters:
mode- TheCommandLineParser.Modefor the argument.mandatory- True if this argument is mandatory for this action.verb- The verb name. Never null. Can beCommandLineParser.GLOBAL_FLAG_VERB.directObject- The action name. Can beCommandLineParser.NO_VERB_OBJECT.shortName- The one-letter short argument name. Can be empty but not null.longName- The long argument name. Can be empty but not null.description- The description. Cannot be null.defaultValue- The default value (or values), which depends on the selectedCommandLineParser.Mode. Can be null.
-
-
Method Detail
-
isMandatory
public boolean isMandatory()
Return true if this argument is mandatory for this verb/directobject.
-
getShortArg
public java.lang.String getShortArg()
Returns the 1-letter short name of the argument, e.g. -v.
-
getLongArg
public java.lang.String getLongArg()
Returns the long name of the argument, e.g. --verbose.
-
getDescription
public java.lang.String getDescription()
Returns the description. Never null.
-
getVerb
public java.lang.String getVerb()
Returns the verb for that argument. Never null.
-
getDirectObject
public java.lang.String getDirectObject()
Returns the direct Object for that argument. Never null, but can be empty string.
-
getDefaultValue
public java.lang.Object getDefaultValue()
Returns the default value. Can be null.
-
getCurrentValue
public java.lang.Object getCurrentValue()
Returns the current value. Initially set to the default value. Can be null.
-
setCurrentValue
public void setCurrentValue(java.lang.Object currentValue)
Sets the current value. Can be null.
-
getMode
public CommandLineParser.Mode getMode()
Returns the argument mode (type + process method). Never null.
-
isInCommandLine
public boolean isInCommandLine()
Returns true if the argument has been used on the command line.
-
setInCommandLine
public void setInCommandLine(boolean inCommandLine)
Sets if the argument has been used on the command line.
-
-