Skip to content

Syntax error in auto-completion script #2336

@rsenden

Description

@rsenden

We have some picocli commands that can process instructions defined in an 'action' YAML file, with the YAML file defining acceptable CLI options (i.e., somewhat similar to picocli @Option). To have picocli accept and pass these options to our command, we use the following in our command implementation:

@Unmatched private String[] actionArgs;

As we want the synopsis to show a generic placeholder for these unmatched arguments, we add a dummy picocli option like the below:

@Option(names="--<action-parameter>", paramLabel="<value>") 
private List<String> dummyForSynopsis;

However, the special characters in the option name cause syntax errors in the command completion script generated by picocli:

-bash: ./fcli_completion: line 6357: syntax error near unexpected token `<'
-bash: ./fcli_completion: line 6357: `    --<action-parameter>)'

Of course, as an easy work-around, we could just rename this option to --action-parameter, but users may interpret this as a literal option name rather than generic placeholder. Also, ideally this dummy option shouldn't even be present in the completion script.

Can you think of any quick fixes/work-arounds to have something like --<action-parameter> listed in synopsis (and manual pages), but not included in the completion script?

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: auto-completionAn issue or change related to auto-completion

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions