Skip to content

Vararg positional parameters should not consume options #285

@remkop

Description

@remkop

Bug reported in #284: positional parameters with arity = "*" (varargs) will greedily consume the remaining command line arguments, even arguments that are options. This does not follow the specification as described in the Mixing Options and Positional Parameters section of the user manual.

For example, this command:

class Cmd {
    @Option(names = "--alpha") String alpha;
    @Parameters(index = "0", arity = "1") String foo;
    @Parameters(index = "1..*", arity = "*") List<String> params;
}

Given command line arguments like this:

<cmd> foo xx --alpha --beta 

Expected result:

alpha  = --beta
foo    = foo
params = [xx]

Actual result:

cmd.foo == 'foo'
cmd.params == ['xx', '--alpha', '--beta']

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions