Skip to content

Cmdliner completions break if CMDLINER_LEGACY_PREFIXES is true at --__complete time #262

@WardBrian

Description

@WardBrian

For example, this actually works fine:

$ CMDLINER_LEGACY_PREFIXES=1 stanc -<TAB>
-?                              --debug-generate-inits          --debug-transformed-mir         --info                          --print-cpp

But this, which would usually be equivalent, does not:

$ export CMDLINER_LEGACY_PREFIXES=1
$ stanc -<TAB>
Usage: %%NAME%% [--help] [OPTION]… [MODEL_FILE]
stanc: option - ambiguous and could be one of --O0, --O1, --Oexperimental,

In some ways this seems silly -- it's listing all the valid completions in the error message!

To directly see the issue, the same error arises if you

$ CMDLINER_LEGACY_PREFIXES=1 stanc --__complete --__complete=-

(it works fine if there are prefixes used before the --_complete= item, or if it's unambiguous, like in stanc this does offer valid completions even though the argument names are auto-format and canonicalize: $ CMDLINER_LEGACY_PREFIXES=1 stanc --__complete --__complete=--canon=<TAB>)


In particular, this means that the patch you suggest here and here breaks completion for more or less all options, as - will always be highly ambiguous. Some sort of special-casing seems worthwhile?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions