public class Arguments
extends java.lang.Object
option_args* free_form*where each element in option_args is an option starting with a '-' character and each element in free_form is a string. Option arguments have the syntax:
'-'NAME[=VALUE]where NAME is the option identifier and VALUE is the string argument for that option.
An example use of the class is as follows:
static void main(String[] args) { Arguments cl = new Arguments(); cl.parse(args); if (cl.getOption("verbose") != null) ... ; String file = cl.getArgument(0); String path = cl.getOption("classpath");
Modifier and Type | Class and Description |
---|---|
static class |
Arguments.Arg |
static class |
Arguments.MissingArgumentError |
static class |
Arguments.Opt
Optional arguments.
|
static class |
Arguments.Req
Required arguments.
|
Constructor and Description |
---|
Arguments()
Create a new CommandLine object with no arguments.
|
Arguments(java.lang.String[] args)
Create a new CommandLine object with an initial argument array.
|
Modifier and Type | Method and Description |
---|---|
int |
addArgument(java.lang.String str,
java.lang.String next)
Add a new argument to this command line.
|
<TArg extends Arguments.Arg> |
extract(TArg arg) |
java.lang.String |
get(int i) |
java.lang.String |
getValue(java.lang.String name)
Return the value of a binding (e.g.
|
int |
size()
Returns the number of remaining command line arguments.
|
java.lang.String |
toString() |
java.lang.String[] |
toStringArray() |
public Arguments(java.lang.String[] args)
args
- array of options and argument that will be parsed.public Arguments()
public int size()
public java.lang.String get(int i)
public int addArgument(java.lang.String str, java.lang.String next)
str
- a stringpublic <TArg extends Arguments.Arg> TArg extract(TArg arg) throws Arguments.MissingArgumentError
Arguments.MissingArgumentError
public java.lang.String getValue(java.lang.String name)
name
- string name of the option or bindingpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String[] toStringArray()