cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.97k stars 334 forks source link

Implements #539: `@Parameters(parametersValidators = <? extends IParametersValidator>)` #542

Closed mkarg closed 2 years ago

mkarg commented 2 years ago

This PR proposes a solution to #539 by adding the new interface IRule, and the new rules attribute to @Paramters. An example demonstrating mutual exclusive parameters is excluded. Also a test is included.

In contrast to #539 I dediced that it makes more sense to have rules at the @Parameters annotation on the class rather than rules on the single @Parameter level. The reason is that it would be confusing for the reader if a rule spanning over two parameters is just provided at one parameter annotation. This situation cannot happen if rules can only be given at the class annotation instead of the field annotation.

mkarg commented 2 years ago

@cbeust I would kindly request your review please. :-)

mkarg commented 2 years ago

ℹ️ In contrast to the original comment, this PR implements #539 using different names than originally proposed. The new interface is called IParametersValidator (instead of IRule), and the annotation field is named parametersValidators (instead of rules).