This is the tenth of a series of posts on some of the personal projects I’ve been working on. As I hope you’ll see, they all fit together. The previous post covered MicroBean Maven CDI. The next post covers MicroBean Launcher.
MicroBean Commons CLI provides a CDI portable extension that sets up a producer method that produces a
CommandLine if there is an
Options CDI bean instance in the current CDI container, and if something somewhere makes the command-line arguments available as a
String qualified with
@Named("commandLineArguments") (it just so happens that MicroBean Main does this).
To install MicroBean Commons CLI, place it (and its dependencies) on your classpath.
This means that if your application has a producer method in it that returns an
Options, and MicroBean Commons CLI is on the classpath, then you can
CommandLine anywhere you like, which gives you access to command line option processing. This, in turn, means that your CDI bean can process command line options easily and intelligently, even though in all likelihood you probably didn’t write the
public static void main(String) method. See my post on MicroBean Main for more on this general pattern.