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.79k stars 414 forks source link

Recursive subcommand could give better error #2293

Open battery-staple opened 1 month ago

battery-staple commented 1 month ago

This is a very minor issue. I accidentally created a command that has itself as a subcommand, like this:

import picocli.CommandLine.Command;

@Command(name = "bad", subcommands = BadCommand.class)
public class BadCommand {

}

While this is of course incorrect, it gives a fairly opaque error: error: FATAL ERROR: java.util.regex.PatternSyntaxException: Stack overflow during pattern compilation near index 9.

It might save someone else in the future a bit of trouble if this gave a more descriptive error. :-)

remkop commented 1 week ago

@battery-staple Thank you for raising this. Is this something that happens in picocli's annotation processor during compilation, or in picocli's reflection code at runtime? Is there a full stack trace you can provide?