How to force a parameter to be the last? #1996
-
I have one parameter and a number of options. How to configure so that the parameter must take the last position? |
Beta Was this translation helpful? Give feedback.
Answered by
remkop
Apr 9, 2023
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
remkop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 theCommandLine
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.