Inspired by other commmand line libraries, I decided to make my own Java flag
command line library here. It makes use
of Java’s Reflection capabilities to fill in the values of flags at runtime.
The library is fairly simple to use–it requires only declaring a static
field, and one invocation to
Flags.parse in the
main method of the
application. The library offers support for various wrapper types as well
as collection types.
As an example of using the library, you declare a flag using the
@FlagInfo with the desired flag names and values.
Then you provide flag values at the command line like so:
All classes referenced from the main class with flags will be available as options.
In addition to learning how to use Java’s Reflection capabilities, this was also an exercise in learning how to use Maven to build and deploy my project. I am using a github project as a maven server.
README.md in the github directory for more information on how to
use it and install the library.