Package org.apache.felix.gogo.options
Interface Option
- All Known Implementing Classes:
Options
public interface Option
-
Method Summary
Modifier and TypeMethodDescriptionget remaining non-options args as Objects.args()
get remaining non-options args as Strings.get value of named option.get list of all values for named option.int
get value of named option as a Number.get value of named option as an Object.getObjectList
(String name) get list of all Object values for named option.boolean
test whether specified option has been explicitly set.parse arguments.parse arguments.parse arguments.parse arguments.setOptionsFirst
(boolean optionsFirst) require options to precede args.setStopOnBadOption
(boolean stopOnBadOption) stop parsing on the first unknown option.void
usage()
print usage message to System.err.usageError
(String error) print specified usage error to System.err.
-
Method Details
-
setStopOnBadOption
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
require options to precede args. Default is false, so options can appear between or after args.- Parameters:
optionsFirst
-
-
parse
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:
-
parse
parse arguments. -
parse
parse arguments. -
parse
parse arguments. -
isSet
test whether specified option has been explicitly set.- Parameters:
name
-- Returns:
-
get
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
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
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
get list of all Object values for named option.- Parameters:
name
-- Returns:
-
getNumber
get value of named option as a Number.- Parameters:
name
-- Returns:
- Throws:
IllegalArgumentException
- if argument is not a Number.
-
args
get remaining non-options args as Strings.- Returns:
- Throws:
IllegalArgumentException
- if args are not Strings.
-
argObjects
get remaining non-options args as Objects.- Returns:
-
usage
void usage()print usage message to System.err. -
usageError
print specified usage error to System.err. You should explicitly throw the returned exception.- Parameters:
error
-- Returns:
- IllegalArgumentException
-