java.lang.Object
com.aoapps.lang.util.GetOpt
General-purpose command line argument processor. Supports options in the
"--option=value" format.
boolean
options default to true if no
value provided. Also supports a single "--" that is used to separate
parameters from non-parameters. All arguments start with -- before the "--"
must be valid parameters.- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptiongetArguments
(String[] args) Gets all of the non-parameter arguments.static <T> T
Gets an argument of the provided type.static <T> T
Parses a String value to the provided type.
-
Method Details
-
parse
Parses a String value to the provided type. Values are converted by:- Special handling for primitive types
public static valueOf(String)
method- public constructor with single
String
parameter
-
getOpt
Gets an argument of the provided type. If the argument is found multiple times, only the most recent value is used. The argument should be in the form --name= value. Boolean arguments are unique in that the value is optional, when not provided it defaults totrue
. "--" may be used to separate parameters from arguments.- Parameters:
args
- the values used during the processing of the parameters will be set to null- Returns:
- the converted value or
null
if not found - See Also:
-
getArguments
Gets all of the non-parameter arguments. If any arguments start with "--" and are not a valid parameter, throws IllegalArgumentException. "--" may be used to separate parameters from arguments. The "--" will be included in the arguments returned.
-