cbeust/jcommander — Issue #90: Accepting a single main parameter doesn't appear to be possible
Author: trejkaz
Created: 2011-11-22 02:06:23+00:00
State: open

We only support opening a single case at a time, so I figured I would just use this for accepting the location as the main parameter:

@Parameter(descriptionKey = "DesktopMainArguments.docLocation")
public File docLocation;

Attempting to parse then throws the following exception:

com.beust.jcommander.ParameterException: Main parameter field public java.io.File com.acme.main.MainArguments.docLocation needs to be of type List, not class java.io.File

I'm sure I could change it to a list, but then I would have to put in boilerplate to check that the user hasn't specified more than one. Is there a proper way to do this directly? Because I can't seem to find it in the examples or in the API.

I thought validation might be the way to do it, but I suspect I was wrong about that because the validator receives the original command-line string, not the final converted object.