Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force parameters to follow options #2103

Open
ddsharpe opened this issue Sep 1, 2023 · 2 comments · May be fixed by #2115
Open

Force parameters to follow options #2103

ddsharpe opened this issue Sep 1, 2023 · 2 comments · May be fixed by #2115

Comments

@ddsharpe
Copy link

ddsharpe commented Sep 1, 2023

As documented in paragraph 3.7, "From picocli 2.0, positional parameters can be specified anywhere on the command line, they no longer need to follow the options." Is it possible with PicoCLI 4.x to create the original behavior or something similar?

Want this to work "command -a X -version 1.2 -- --optA --optB=4".
Want this to fail "command -a X -version 1 2 -- --optA --optB=4". (user typo'd the decimal for option "version")

The parameters are declared like
@parameters
List extraParamaters;
but this prevents the parser from catching the typo. If I want all parameters to come after options or even after --, is it possible to configure the framework to do this? If so, I would expect the parser to catch that the "2" is a mismatched parameter, right?

@remkop
Copy link
Owner

remkop commented Sep 2, 2023

Currently, the -- End Of Options delimiter only means that what follows are positional parameters, but that doesn't prevent that some of the preceding arguments may also be positional parameters.

Your feature request is to introduce a parser configuration that results in an error message if any positional parameters are found prior to the -- End Of Options delimiter, or when any positional parameters are found without the -- End Of Options delimiter being present.

I don’t oppose this, but I won’t have time to work on this myself. Will you be able to provide a pull request with tests for this?

@ddsharpe
Copy link
Author

Hope to have a PR this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants