This is just an example, a suggestion, a "generic" way to do the job.
Like when you have the possibility to add those parameters to your command line, like in
$ java -cp archive.jar sample.SampleMain --first-prm:value01 --second-prm:123 --third-prm:true
The goal here is to show a way to parse those parameter and extract the expected values, for the rest of the process to use them.
Look into the code, how we are using BiConsumer<String, CLIPrm>
. The parsing itself happens in the main
method, obviously.
$ java -cp archive.jar sample.SampleMain --help
would display
CLI Parameters:
--help, Help!!!
--first-prm:, String example.
--second-prm:, Headless version.
--third-prm:, Headless version.
And
$ java -cp archive.jar sample.SampleMain --first-prm:value01 --second-prm:123 --third-prm:true
would display
Managed --first-prm:, String example., --first-prm:value01
Managed --second-prm:, Int example., --second-prm:123
Managed --third-prm:, Boolean example., --third-prm:true
Value One: value01
Value Two: 123
Value Three: true
. . .