For writing command line applications in Java, what is the best library for parsing and managing arguments and paramenters?
Note: this question is an updated version of this closed question on Stack Overflow.
Software Recommendations Stack Exchange is a question and answer site for people seeking specific software recommendations. It only takes a minute to sign up.Sign up to join this community
picocli is different from other Java CLI libraries:
Example usage help message:
<command> -xvfInputFileas well as
<command> -x -v -f InputFile)
Usage help is the face of your application, so be creative and have fun!
Picocli is also actively maintained. Since the original post, many new features were added, for example:
@Parameters(picocli creates a synthetic implementation that returns the matched options)
@Parameters(so you can validate options and positional parameters)
@Commandmethods for extra compact code
Disclaimer: I am the author.
I recommend JOpt Simple. It 'attempts to honor the command line option syntaxes of POSIX getopt() and GNU getopt_long().' It has community traction and notably is the command line parsing lib of choice for the OpenJDK itself.
For comparison, here's a relatively up to date (as of Jan 2015) list of related libraries that serve the same purpose.