I am trying to port a CLI to use JCommander but my application allows for custom parameters to be passed on the command line like this:
./App.sh -u myusername -customparam1 customval1
In that case customparam1
is the name of the custom parameter and customval1
is its value. The user can pass an arbitrary number of such parameters and the names can be anything, e.g. customparam2
, etc.
Is JCommander capable of parsing those type of parameters? I tried using Dynamic Parameters but there were two problems:
- they appear to require a prefix before the parameter name, e.g.
-Dcustomparam1
, whereD
is the prefix - they require an assignment character such as
=
between the name and the value, and space will not work as the assignment character
Any suggestions about how to use JCommander for parsing these params?