JCommander is very good command line parsing framework for Java.
"Because life is too short to parse command line parameters" © Cédric Beust
JCommander not only can parse program arguments, it also has an extension point for validation of argument values.
At the same time JCommander does not contain (at least in version 1.64
) any validators.
This library is designed to correct this omission.
Some validators is ready to use
, but I can't guess all useful cases and many validators designed to be useful after simple extension without any logic implementation.
Example: if you need validate argument value to be within some borders, you need only:
- extend class
InRange
- create default constructor
- pass in super constructor required borders
- use your class in
@Parameter#validateValueWith
Validators list:
- Common
- Range:
InRange
,NotInRange
- Collection:
InCollection
- Range:
- Number
- Equal:
EqualTo
,NotEqualTo
- Greater:
GreaterThan
,GreaterThanOrEqualTo
- Less:
LessThan
,LessThanOrEqualTo
- Zero-compare:
EqualToZero
,NotEqualToZero
,GreaterThanZero
,GreaterThanOrEqualToZero
,LessThanZero
,LessThanOrEqualToZero
- Equal:
- String
- Simple:
NotBlank
,NotEmpty
- Pattern based:
PatternContains
,PatternNotContains
,PatternMatched
,PatternNotMatched
- Simple:
- IO
- Base:
Exists
,NotExists
- File:
ExistsFile
,ExistsFileReadable
,ExistsFileWritable
,ExistsFileExecutable
- Directory:
ExistsDirectory
,ExistsDirectoryReadable
,ExistsDirectoryWritable
,ExistsDirectoryExecutable
- Base:
- NIO
- Base:
Exists
,NotExists
- File:
ExistsFile
,ExistsFileReadable
,ExistsFileWritable
,ExistsFileExecutable
- Directory:
ExistsDirectory
,ExistsDirectoryReadable
,ExistsDirectoryWritable
,ExistsDirectoryExecutable
- Link:
ExistsLink
,ExistsLinkReadable
,ExistsLinkWritable
,ExistsLinkExecutable
- Base:
Build with code coverage report: clean package jacoco:report