Skip to content

Arity should not limit the total number of values put in an array or collection #191

@remkop

Description

@remkop

As of 1.0.1, arity on a list/array field is treated by picocli as a global max.
If more values are put into the list/array for any reason, a MaxValuesforFieldExceededException exception is thrown. This should not happen.

Example

For example, if a collection or array option is defined with arity="1":

class Args {
    @Option(names = "-o", arity="1")
    List<String> strings;
}

Current (incorrect)

Currently picocli (incorrectly) throws an exception if the option is specified multiple times:

<command> -o AA -o BB -o CC
# results in MaxValuesforFieldExceededException ...

Correct

Arity defines the number of parameters that the option takes. The option itself can be specified multiple times:

<command> -o AA -o BB -o CC

assert strings.size() == 3

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions