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.94k stars 424 forks source link

Recursive subcommand could give better error #2293

Open battery-staple opened 6 months ago

battery-staple commented 6 months 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 5 months 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?