See: Description
| Interface | Description |
|---|---|
| CliModeObject |
This is a container for a
CliMode together with additional associated information. |
| CliParser |
This is the interface used to
parse the command-line arguments of a main-program. |
| CliParserBuilder |
| Class | Description |
|---|---|
| AbstractMain |
This is the abstract base class for a main-program.
|
| AbstractVersionedMain |
This is the abstract base class for a
main-program that has a version. |
| CliOptionNameDefaultFilter | |
| CliOutputSettings |
This class represents the settings for the
help output. |
| Enum | Description |
|---|---|
| CliContainerStyle |
This enum contains the available styles for container types.
|
| CliStyleHandling |
This enum contains the available ways to handle a specific CLI-style.
|
| Annotation Type | Description |
|---|---|
| CliArgument |
A
CliArgument is used to annotate a property (member variable of some class or setter-method) that should be
set from a main-program via a commandline argument. |
| CliClass |
A
CliClass is used to annotate a Java-class that holds the parameters of a main-program that are parsed from
the commandline arguments. |
| CliMode |
A
CliMode is used to annotate a CLI annotated class in order to define a operational mode. |
| CliModes | |
| CliOption |
A
CliOption is used to annotate a property (member variable of some class or setter-method) that should be
set from a main-program via a commandline option. |
| CliStyle |
A
CliStyle is used to annotated a Java-class that holds the parameters of a main-program that are parsed from
the commandline arguments. |
public static void main(String[] args)However you quickly notice that this was NOT the end of wisdom when designing an object-oriented language as java. A main-program often starts easy and then over the time options and arguments are added. When you want to write a maintainable main-program you want to have more infrastructure than just having a string-array lost in a static method.
AbstractMain and
AbstractVersionedMain that you can extend to build your main program. For each
option and argument there are
Annotations to annotate your regular Fields. Via
CliMode multiple modes can be defined to realize complex scenarios. Everything
integrates with javax.validation (BV) and our excellent native-language-support including text wrapping and
hyphenation. So you do not have to maintain any usage or help output that
is all done for you.
@CliMode(id =CliMode.ID_DEFAULT, usage = NlsBundleMyExampleRoot.MSG_MAIN_MODE_USAGE_DEFAULT) public class MyCoolMain extendsAbstractVersionedMain{ @CliOption(name = "--flag", aliases = "-f", usage = NlsBundleMyExampleRoot.MSG_MAIN_OPTION_FLAG) private boolean flag; @Overridepublic intrunDefaultMode(){ if (this.flag) { // ... do this ... } else { // ... do that ... } } public static void main(String[] args) { new MyCoolMain().runAndExit(args); } }
String[] args). Such parameter is either an option or a
value. A value can belong to an option or an
argument. E.g. the parameters --port 8080 start consist
of the option --port with its value 8080 and the argument start.Copyright © 2001–2016 mmm-Team. All rights reserved.