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.
https://picocli.info
Apache License 2.0
4.8k stars 414 forks source link

multiple occurrences with limit of occurrence times #2233

Closed gwttk closed 3 months ago

gwttk commented 3 months ago

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

remkop commented 3 months ago

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.

gwttk commented 3 months ago

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.