Validation on provided help-parameter

15 views
Skip to first unread message

Lars K.

unread,
Jul 1, 2017, 1:40:00 AM7/1/17
to jcommander
Hello,

I have a problem with/ a question regarding my use of JCommander.
I have an option-parameter with help=true set and several commands (containing command options) declared.

I want to use the general functionality of the parse-validation, can't find a way to get it work as I want with your current implementation though.
In the main class (JCommander.java) in the method validateOptions (which is called when using default parse method) there is a check on the 'helpWasSpecified' flag, which (when set to true) prohibits the validation. In the parseValues method however, this flag gets set if the help parameter is found, but there are still exceptions thrown on unknown commands/options, even if the help option has already been parsed.

In my personal intuition/understanding, if the help-parameter is given (not even as the first option, but anywhere), no validation at all should be performed.
To use the parseWithoutValidation generally is not an option for me, but maybe it could be possible, to use a call which generally uses validation, but first checks for the help-option, and if it is given stops any further validation.

Maybe a workaround would be just to check the input arguments for the help-option first before even using the parse-method.
Is there an option for this behaviour I missed and what are your general thoughts about my problem?

Thanks in advance
Lars
Reply all
Reply to author
Forward
0 new messages