#defaultsTo should be varg, not value, varg #8

Closed
cwensel opened this Issue Nov 4, 2011 · 4 comments

Comments

Projects
None yet
2 participants

cwensel commented Nov 4, 2011

ArgumentAcceptingOptionSpec#defaultsTo(v,varg) prevents me from adding the defaults as a String[] value

Thus this,

parser.accepts("some-values").withRequiredArgs().defaultTo( SOME_ARRAY );

won't compile.

Collaborator

pholser commented Nov 4, 2011

Sounds reasonable -- though I am leaning toward offering both defaultsTo(V, V...) and defaultsTo(V[]), to disallow at compile time the pathological defaultsTo() with no args.

Note also that this doesn't help with primitive arrays:

OptionSpec<Integer> c = parser.accepts("c").withRequiredArg().ofType(Integer.class).defaultsTo(new int[] { 1, 2 });

(Thanks, Java. 8^| )

Would offering both defaultsTo(V, V...) and defaultsTo(V[]) suit your needs?

cwensel commented Nov 4, 2011

Sure thing. Trying to deconstruct an array to fit into (V,V...) is darn ugly.

Collaborator

pholser commented Nov 4, 2011

Right on. I'll roll this in shortly.

Collaborator

pholser commented Nov 5, 2011

Resolved in 4.2. Thanks for pointing this out!

pholser closed this Nov 5, 2011

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