Modifier and Type | Class and Description |
---|---|
static class |
Args.ArgsParsingException
A custom exception raised when encountering an error while
parsing command-line arguments.
|
static class |
Args.Type
An enumeration type listing the different types
of options that can be expected in the CLI.
|
static class |
Args.Value
Common variant type holding values associated to various
types
of command-line options. |
Modifier and Type | Method and Description |
---|---|
List<String> |
getExtras()
Arguments are listed in order of appearance on the command line.
|
boolean |
getFlag(org.stekikun.dolmen.cli.Args.Item item) |
int |
getNumeric(org.stekikun.dolmen.cli.Args.Item item) |
String |
getString(org.stekikun.dolmen.cli.Args.Item item) |
static void |
main(String[] args)
An entry point for testing argument parsing only
|
static Args |
parse(String[] args)
Parses the given array of command-line arguments
args according
to the various available options described in Args.Item . |
String |
toString() |
public boolean getFlag(org.stekikun.dolmen.cli.Args.Item item)
item
- item
IllegalArgumentException
- if item
is not of type Args.Type.FLAG
public int getNumeric(org.stekikun.dolmen.cli.Args.Item item)
item
- item
IllegalArgumentException
- if item
is not of type Args.Type.NUMERIC
public String getString(org.stekikun.dolmen.cli.Args.Item item)
item
- item
IllegalArgumentException
- if item
is not of type Args.Type.STRING
public List<String> getExtras()
public static Args parse(String[] args) throws Args.ArgsParsingException
args
according
to the various available options described in Args.Item
.
The expected format of the command-line arguments is as follows:
--name
-n
value
of some type
,
the value must directly follow the option in the argument array;
flag
options require no value
-lah
, provided all given options
are flags
extra arguments list
.
args
- Args
which contains the result of
the parsing of args
Args.ArgsParsingException
- if an error is encountered while parsing args
getFlag(Item)
,
getNumeric(Item)
,
getString(Item)
,
getExtras()
public static void main(String[] args)
args
-