remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.

Home Page:https://picocli.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple occurrences with limit of occurrence times

gwttk opened this issue · comments

It could be very useful if we can force the size of resulted arrays.
for example

@Option(names = { "-f" }, size = "2")
public String[] file;
@Option(names = { "-d" }, size = "1..3")
public String[] dir;

So the file array must be a size of 2. dir array can be [1,3].
-d DIR1 -f FILE1 -d DIR2 -f FILE2

Yes, I have considered supporting this in the annotations API but this is very straightforward to implement in your application by throwing a ParameterException (see Custom Validation), and I decided to put my effort towards other things.

Yes, I have considered supporting this in the annotations API but this is very straightforward to implement in your application by throwing a ParameterException (see Custom Validation), and I decided to put my effort towards other things.

ParameterException ! OK you convinced me.