java.lang.Object
io.github.mmm.cli.CliMain
This is the abstract base class for a main-program.
You simply need to extend this class and implement
You simply need to extend this class and implement
run(CliArgs). For advanced CLIs please extend
io.github.mmm.nls.cli.NlsMain from mmm-nls-cli.- Since:
- 1.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconsole()protected voiderror(CliArgument argument) protected intprotected Stringabstract intHas to be implemented to handle that givenCliArgsand do the program logic.intprotected voidrunAndExit(String... args) This method delegates torun(String...)and then callsSystem.exit(int)with the returned exit code.
-
Field Details
-
c
- See Also:
-
-
Constructor Details
-
CliMain
public CliMain()The constructor. -
CliMain
The constructor.- Parameters:
console- theCliConsoleto use.
-
-
Method Details
-
console
- Returns:
- the
CliConsole.
-
error
- Parameters:
argument- theCliArgumentthat was unexpected at this place.
-
error
-
getVersion
- Returns:
- the version of this program.
-
run
Has to be implemented to handle that givenCliArgsand do the program logic. -
run
This method parses the givenargsasCliArgsand delegates torun(CliArgs). Additionally it will catch and handle any kind oferrors.- Parameters:
args- are the command-line arguments.- Returns:
- the
exit code.
-
runAndExit
This method delegates torun(String...)and then callsSystem.exit(int)with the returned exit code. Typically you only need to call this method from your actualmainmethod.- Parameters:
args- are the command-line arguments.
-