Variable arity with different types

29 views
Skip to first unread message

Brendan Robert

unread,
Sep 25, 2017, 12:11:09 PM9/25/17
to jcommander
Hey guys I have a quick question. I am attempting to include a parameter that should allow one or two arguments and i would like the first argument to be a string and the second to be boolean. How can I model my Args object to allow for a number of inputs that look like the following:

-v strA true      -v strB

and i would like to see that I have two of these -v objects in a list with the first one as true and the second one as not specified so resort to whatever my default would be. At the end of the day the strings are going to be class names that will be instantiated through reflection and the optional boolean flag would point to additional program specifics for that class. Im used to only doing a single -v strA strB and a single --submit flag to provide the optional detail for all strings but i want the ability to capture for each string. Thanks! 

Cédric Beust ♔

unread,
Sep 25, 2017, 12:13:09 PM9/25/17
to jcommander
Make your parameter a list of objects and you'll have to perform some manual scanning to determine which argument is what.

-- 
Cédric


--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages