picocli is different from other Java CLI libraries:
- It is designed to be included in source form. This lets users run picocli-based applications without requiring picocli as an external dependency.
- Generates polished and easily tailored usage help, using ANSI colors when the underlying platform supports it.
- Autocompletion for your Java command line applications on supported platforms
Example usage help message:
Quick overview:
- Effortless command line parsing - just annotate fields
- Strongly typed everything - command line options as well as positional parameters
- full support for both GNU style and POSIX clustered short options (so it handles
<command> -xvfInputFile
as well as<command> -x -v -f InputFile
) - An arity model that allows a minimum, maximum and variable number of parameters, e.g,
"1..*"
,"3..5"
- Subcommands
- Works with Java 5 and higher
- Well-structured user manual
Usage help is the face of your application, so be creative and have fun!
Update:
Picocli is also actively maintained. Since the original post, many new features were added, for example:
- programmatic API as well as annotations API
- Dependency Injection container integration
- JLine integration: delegate to AutoComplete for your command’s Completer implementation
- interface methods can be annotated with
@Option
or@Parameters
(picocli creates a synthetic implementation that returns the matched options) - class methods can be annotated with
@Option
or@Parameters
(so you can validate options and positional parameters) - support for
@Command
methods for extra compact code - internationalization with resource bundles
Disclaimer: I am the author.