Picocli builds rich CLI applications in Java with annotations or a programmatic API, including ANSI help, subcommands, and bash or zsh completion. A single-source-file mode lets apps avoid a separate dependency.
Overview
Picocli targets JVM and GraalVM native-image CLIs where developers want typed options, nested subcommands, and polished usage help without boilerplate. Annotations map fields and methods to arguments, while CommandLine.execute handles parsing, exit codes, and help requests.
Features include POSIX-style grouped short options, @-files for long command lines, negatable options, argument groups for mutual exclusion, and password prompts. Completion scripts for bash and zsh and JLine shell modules support interactive tools.
GraalVM native-image integration uses an annotation processor to embed reflection configuration, enabling compact executables with fast startup. Integrations exist for Spring Boot, Micronaut, Quarkus, Guice, and CDI containers.
The library runs on Java 5 through current releases and is used by projects such as JUnit’s ConsoleLauncher and ktlint.
Key features
- Annotation and programmatic CLI API
- Nested subcommands and git-style UX
- ANSI-styled usage and version help
- Bash and zsh autocompletion scripts
- GraalVM native-image support
- Single-file copy-paste distribution
- Spring Boot and Quarkus integrations
Use cases
- Build Java CLI tools with minimal boilerplate
- Compile GraalVM native command binaries
- Add subcommands to existing JVM utilities
- Generate shell completion for internal tools