Package org.apache.hadoop.fs.shell
Class CommandFormat
java.lang.Object
org.apache.hadoop.fs.shell.CommandFormat
Parse the args of a command and check the format of args.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed when a duplicated option is supplied to a command.static classUsed when the arguments exceed their boundsstatic classUsed when too few arguments are supplied to a commandstatic classUsed when too many arguments are supplied to a commandstatic classUsed when an unsupported option is supplied to a command -
Constructor Summary
ConstructorsConstructorDescriptionCommandFormat(int min, int max, String... possibleOpt) Simple parsing of command line argumentsCommandFormat(String name, int min, int max, String... possibleOpt) Deprecated.use replacement since name is an unused parameter -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOptionWithValue(String option) add option with valuebooleanReturn if the option is set or notgetOpts()Returns all the options that are setgetOptValue(String option) get the option's valueParse parameters starting from the given position Consider using the variant that directly takes a ListvoidParse parameters from the given list of args.
-
Constructor Details
-
CommandFormat
Deprecated.use replacement since name is an unused parameter- Parameters:
name- of command, but never usedmin- see replacementmax- see replacementpossibleOpt- see replacement- See Also:
-
CommandFormat
Simple parsing of command line arguments- Parameters:
min- minimum arguments requiredmax- maximum arguments permittedpossibleOpt- list of the allowed switches
-
-
Method Details
-
addOptionWithValue
add option with value- Parameters:
option- option name
-
parse
Parse parameters starting from the given position Consider using the variant that directly takes a List- Parameters:
args- an array of input argumentspos- the position at which starts to parse- Returns:
- a list of parameters
-
parse
Parse parameters from the given list of args. The list is destructively modified to remove the options.- Parameters:
args- as a list of input arguments
-
getOpt
Return if the option is set or not- Parameters:
option- String representation of an option- Returns:
- true is the option is set; false otherwise
-
getOptValue
get the option's value- Parameters:
option- option name- Returns:
- option value if option exists, but no value assigned, return "" if option not exists, return null
-
getOpts
Returns all the options that are set- Returns:
- Set<String> of the enabled options
-