Because sometimes making a CLI can be a real pain in the a$$
- combine some libraries that work: argparse4j, jansi, cli-progress
- easily make a CLI app that is extensible
- remove some boilerplate code
This library uses Java's ServiceLoader to gather up all the CliCommands in the application's classpath. This makes it really easy for anyone to add a new command they "wish" they had in your application.
I would suggest checking out the example module. This is an example of how to setup an application with maven.
Base requirements
- Make the
cli.pi.CliAppyourMain-Classin yourMANIFEST.MFso your commands will be picked up and exceptions will be handled - Create file
app-info.propertiesin the root directory of your application. This file expects to have one propertyapp.versionand this is used when a user wants to know the version of our application. - All your commands are expected to extend the class
CliCommandand to have an entry of each command class in theMETA-INF/services/cli.pi.command.CliCommandfile. This can be auto-generated for you if you look in the FAQ.
- Is there anyway to auto-generate the files that get put in
META-INF/servicesfor myCliCommands ?- I usually annotate my
CliCommandimplementations with the@MetaInfServicesannotation provided in themetainf-servicesmodule. This module contains an annotation processor that will generate the service file at compile time based on whatserviceyou declared in the annotation. So you only need this module at compile time and not runtime.
- I usually annotate my