Package org.apache.felix.gogo.options
Interface Option
-
- All Known Implementing Classes:
Options
public interface Option
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<Object>argObjects()get remaining non-options args as Objects.List<String>args()get remaining non-options args as Strings.Stringget(String name)get value of named option.List<String>getList(String name)get list of all values for named option.intgetNumber(String name)get value of named option as a Number.ObjectgetObject(String name)get value of named option as an Object.List<Object>getObjectList(String name)get list of all Object values for named option.booleanisSet(String name)test whether specified option has been explicitly set.Optionparse(Object[] argv)parse arguments.Optionparse(Object[] argv, boolean skipArg0)parse arguments.Optionparse(List<?> argv)parse arguments.Optionparse(List<?> argv, boolean skipArg0)parse arguments.OptionsetOptionsFirst(boolean optionsFirst)require options to precede args.OptionsetStopOnBadOption(boolean stopOnBadOption)stop parsing on the first unknown option.voidusage()print usage message to System.err.IllegalArgumentExceptionusageError(String error)print specified usage error to System.err.
-
-
-
Method Detail
-
setStopOnBadOption
Option setStopOnBadOption(boolean stopOnBadOption)
stop parsing on the first unknown option. This allows one parser to get its own options and then pass the remaining options to another parser.- Parameters:
stopOnBadOption-
-
setOptionsFirst
Option setOptionsFirst(boolean optionsFirst)
require options to precede args. Default is false, so options can appear between or after args.- Parameters:
optionsFirst-
-
parse
Option parse(List<?> argv, boolean skipArg0)
parse arguments. If skipArgv0 is true, then parsing begins at arg1. This allows for commands where argv0 is the command name rather than a real argument.- Parameters:
argv-skipArg0-- Returns:
-
isSet
boolean isSet(String name)
test whether specified option has been explicitly set.- Parameters:
name-- Returns:
-
get
String get(String name)
get value of named option. If multiple options given, this method returns the last one. UsegetList(String)to get all values.- Parameters:
name-- Returns:
- Throws:
IllegalArgumentException- if value is not a String.
-
getList
List<String> getList(String name)
get list of all values for named option.- Parameters:
name-- Returns:
- empty list if option not given and no default specified.
- Throws:
IllegalArgumentException- if all values are not Strings.
-
getObject
Object getObject(String name)
get value of named option as an Object. If multiple options given, this method returns the last one. UsegetObjectList(String)to get all values.- Parameters:
name-- Returns:
-
getObjectList
List<Object> getObjectList(String name)
get list of all Object values for named option.- Parameters:
name-- Returns:
-
getNumber
int getNumber(String name)
get value of named option as a Number.- Parameters:
name-- Returns:
- Throws:
IllegalArgumentException- if argument is not a Number.
-
args
List<String> args()
get remaining non-options args as Strings.- Returns:
- Throws:
IllegalArgumentException- if args are not Strings.
-
usage
void usage()
print usage message to System.err.
-
usageError
IllegalArgumentException usageError(String error)
print specified usage error to System.err. You should explicitly throw the returned exception.- Parameters:
error-- Returns:
- IllegalArgumentException
-
-