Skip to content

Smart conflict resolution when two parameters with variable arity compete to consume a positional argument #70

@remkop

Description

@remkop

Positional parameters with index/arity ranges may make some input ambiguous. In the below example, the argument at index 1 could be either a port or a file.

Example:

class App {
    @Parameters(index = "0..1", arity = "1..2") int[] portRange;
    @Parameters(index = "1..*") String[] files;
}
App app1 = CommandLine.parse(new App(), "3333", "file1", "file2");

This currently gives picocli.CommandLine$ParameterException: Could not convert 'file1' to int[] for parameter[-1]. (Picocli tries to match options in declared order.)

This requires parsing Strings args which may apply until we encounter one that cannot be converted to the target type.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions