picocli v4.7.0-new Release Notes

  • Tracing API

    From picocli 4.7.0, applications can programmatically set the trace level, and use tracing in custom components.

    In addition to setting system property picocli.trace, applications can now change the trace level via the Tracer::setLevel method. For example:


    The new public method CommandLine.tracer() returns the singleton Tracer object that is used internally by picocli, and can also be used by custom component implementations to do tracing. For example:

    class MyIntConverter implements ITypeConverter<Integer> {
        public Integer convert(String value) {
            try {
                return Integer.parseInt(value);
            } catch (NumberFormatException ex) {
                        "Could not convert %s to Integer, returning default value -1", value);
                return -1;

    Enable Consuming Option Names or Subcommands

    0️⃣ By default, options that take a parameter do not consume values that match a subcommand name or an option name.

    🚀 This release introduces two parser configuration options to change this behaviour:

    • CommandLine::setAllowOptionsAsOptionParameters allows options to consume option names
    • CommandLine::setAllowSubcommandsAsOptionParameters allows options to consume subcommand names

    When set to true, all options in the command (options that take a parameter) can consume values that match option names or subcommand names.

    This means that any option will consume the maximum number of arguments possible for its arity.


    If an option is defined as arity = "*", this option will consume all remaining command line arguments following this option (until the End-of-options delimiter) as parameters of this option.

    Unsorted Synopsis

    0️⃣ By default, the synopsis displays options in alphabetical order. Picocli 4.7.0 introduced a sortSynopsis = false attribute to let the synopsis display options in the order they are declared in your class, or sorted by their order attribute.

    @Command(sortSynopsis = false)