-
Notifications
You must be signed in to change notification settings - Fork 446
Description
First of all, thanks for this tool. It is a huge improvement over Commons CLI!
However, I was expecting some of the custom option validation that I had written for CLI to be supported using PicoCLI.
I have an application that accepts several different types of input, i.e. XML files, log files, report names, report ids. These are each implemented as Options, so they can individually be collected in lists:
@option(name="--xml") List xmlFiles;
@option(name="--log") List logFiles;
@option(name="--report-name") List reportNames;
@option(name="--report-id") List reportIDs;
These are neither mutually exclusive, nor dependent. I just need to validate that at least one input is provided to the app, and print the usage/help output otherwise. I can't find a way to do this, and there are no examples on how to add this validation into my business logic.
So my questions are:
- Is there a way to flag these options together as a group to validate that at least one of them is provided on the command line?
- If not, how can I manually indicate that there is an input validation issue from within my application code? Should I throw a particular exception?
- How can I have PicoCLI automatically indicate in the usage string that one of the options is required?
A second, related issue is that each of the options in the example above are already part of their own ArgGroups (with validate=false), so that I can keep them organized with other related flags in the help usage. I do not believe that I can include an option in multiple ArgGroups (please correct me if I am wrong!). Wouldn't it be better to be able to provide a groupName="foo" parameter in the Options attribute to collect items together, so that Options validation can be separated from the organization in the help usage?