Package org.flasby.cli.impl
Class CommandLineImpl
java.lang.Object
org.flasby.cli.impl.CommandLineImpl
- All Implemented Interfaces:
CommandLine
- Author:
- flasbyst
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreturns the value of the default, if any.String[]
returns an array of values containing all the values provided as defaults.returns all the options parsed by this commandline instance.boolean
returns the value of the flag.returns the value of the option, if any.String[]
getValues
(OptionList option) returns an array of values containing all the values provided for this option.boolean
informs if a default Option was provided on the commandline.boolean
wasProvided
(Option option) informs if the specified Option was provided on the commandline.
-
Constructor Details
-
CommandLineImpl
public CommandLineImpl(Options options, String[] args) throws UnknownArgumentException, MissingRequiredOptionException
-
-
Method Details
-
wasProvided
Description copied from interface:CommandLine
informs if the specified Option was provided on the commandline. Note that missing or unknown arguments will be flagged by a suitable exception.- Specified by:
wasProvided
in interfaceCommandLine
- Parameters:
option
-- Returns:
-
getValues
Description copied from interface:CommandLine
returns an array of values containing all the values provided for this option. If the option was specified 3 times, then this array could be up to length 3. Note that if only 2 out of the three options actually provided a value, then this array will only have a length of 2. It will never return null. The values will be returned in the order encountered on the command line.- Specified by:
getValues
in interfaceCommandLine
- Parameters:
option
-- Returns:
- an array of all the values provided on the command line for this option.
-
getValue
Description copied from interface:CommandLine
returns the value of the option, if any. If the option was provided more than once and a value was provided more than once then this will return the first one provided.- Specified by:
getValue
in interfaceCommandLine
- Parameters:
option
- - the option value required.- Returns:
- null if the option was not provided or no value for the option was provided, otherwise the actual value of the option.
-
getValue
Description copied from interface:CommandLine
returns the value of the flag. That is, was the flag provided on the commandline.- Specified by:
getValue
in interfaceCommandLine
- Parameters:
flag
-- Returns:
-
wasDefaultProvided
public boolean wasDefaultProvided()Description copied from interface:CommandLine
informs if a default Option was provided on the commandline. By default I mean a value with no option flag, or one preceeded by '- '.- Specified by:
wasDefaultProvided
in interfaceCommandLine
- Returns:
-
getDefaultValue
Description copied from interface:CommandLine
returns the value of the default, if any. If the default value was provided more than once and then this will return the first one provided.- Specified by:
getDefaultValue
in interfaceCommandLine
- Returns:
- null if no default value was provided otherwise the actual value of the option.
-
getDefaultValues
Description copied from interface:CommandLine
returns an array of values containing all the values provided as defaults. That is, all values provided without a prceeding option or preceeded by a '- '. It will never return null. The values will be returned in the order encountered on the command line.- Specified by:
getDefaultValues
in interfaceCommandLine
- Returns:
- an array of all the values provided on the command line for this option.
-
getOptions
Description copied from interface:CommandLine
returns all the options parsed by this commandline instance.- Specified by:
getOptions
in interfaceCommandLine
- Returns:
-