Skip to content

A simple little framework for making Java CLI applications

License

Notifications You must be signed in to change notification settings

born2snipe/cli-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cli-Pi

Because sometimes making a CLI can be a real pain in the a$$

What does it do?

  • combine some libraries that work: argparse4j, jansi, cli-progress
  • easily make a CLI app that is extensible
  • remove some boilerplate code

How does it work?

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.

How do I get started?

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.CliApp your Main-Class in your MANIFEST.MF so your commands will be picked up and exceptions will be handled
  • Create file app-info.properties in the root directory of your application. This file expects to have one property app.version and this is used when a user wants to know the version of our application.
  • All your commands are expected to extend the class CliCommand and to have an entry of each command class in the META-INF/services/cli.pi.command.CliCommand file. This can be auto-generated for you if you look in the FAQ.

FAQ

  • Is there anyway to auto-generate the files that get put in META-INF/services for my CliCommands ?
    • I usually annotate my CliCommand implementations with the @MetaInfServices annotation provided in the metainf-services module. This module contains an annotation processor that will generate the service file at compile time based on what service you declared in the annotation. So you only need this module at compile time and not runtime.

About

A simple little framework for making Java CLI applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages