Skip to content

Investigate feasibility of parser backtracking for ambiguous options #980

@remkop

Description

@remkop

Follow-up on #979, #981, #370, #659

Any time an option has a range of parameters, like @Option(arity = "0..1") or @Option(arity = "1..*"), and the command also defines one or more positional parameters, there is ambiguity whether a command line parameter should be considered an option parameter or a positional parameter.

Sometimes it is possible to resolve the ambiguity locally, and picocli currently applies heuristics to determine if the value is a subcommand or (likely) another option.

In other cases, it may possible to resolve the ambiguity globally: if a command has an option with an optional parameter, and a required positional parameter, then interpreting the parameter following the option (--option value) as a positional parameter is the only interpretation that does not result in an error.

This requires the parser "marking" points of ambiguity and processing the input multiple times, using different interpretations of the "grammar" defined by the command options and parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declined ❌A suggestion or change that we don't feel we should currently applytheme: parserAn issue or change related to the parser

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions