Skip to content

How to force a parameter to be the last? #1996

Closed Answered by remkop
giaphattram asked this question in Q&A
Discussion options

You must be logged in to vote

There's no way in picocli to enforce that positional parameters need to follow the named options.

So any validation will need to be done in the application.

One idea is to get the ParseResult object from the CommandLine object, and call the matchedArgs or expandedArgs method on it to get the matched arguments or the original command line arguments. Then check in your application logic that the last element in the list was the positional parameter.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@giaphattram
Comment options

Answer selected by remkop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants