picocli
picocli copied to clipboard
InitializationException thrown by picocli-codegen on class without direct options
InitializationException
is thrown by picocli-codegen when ArgGroup
is set on a class that has no direct options but extends one that has options.
Example:
@CommandLine.ArgGroup
SpecificOptions options;
static class GenericOptions {
@CommandLine.Option(names = "--verbose")
boolean verbose;
}
static class SpecificOptions extends GenericOptions {
//@CommandLine.Option(names = "--dummy")
//boolean dummyOption;
}
Stacktrace:
error: FATAL ERROR: picocli.CommandLine$InitializationException: ArgGroup has no options or positional parameters, and no subgroups: AnnotatedElementHolder(FIELD options in ArgGroupIssue) in null
at picocli.CommandLine$Model$ArgGroupSpec.<init>(CommandLine.java:10059)
at picocli.CommandLine$Model$ArgGroupSpec$Builder.build(CommandLine.java:10512)
at picocli.codegen.annotation.processing.AbstractCommandSpecProcessor$Context.connectArgGroups(AbstractCommandSpecProcessor.java:997)
at picocli.codegen.annotation.processing.AbstractCommandSpecProcessor$Context.connectModel(AbstractCommandSpecProcessor.java:856)
at picocli.codegen.annotation.processing.AbstractCommandSpecProcessor$Context.access$000(AbstractCommandSpecProcessor.java:807)
at picocli.codegen.annotation.processing.AbstractCommandSpecProcessor.tryProcess(AbstractCommandSpecProcessor.java:194)
at picocli.codegen.annotation.processing.AbstractCommandSpecProcessor.process(AbstractCommandSpecProcessor.java:165)
Gist to reproduce:
https://gist.github.com/charphi/cd915fef9f38edec3994051217728669
Sorry I have had little time to look into this...
Would the problem be resolved by putting the @ArgGroup
annotation on the SpecificOptions
class?
No problem. It is a low-priority bug. I'm able to workaround it by adding a dummy hidden option.
Can you explain the use case a bit? Why do you want to do this?
I'm trying to create a library that can be shared between several cli projects. This library contains default options to (for example) read/write csv and yaml files. I need to extends these options if needed and sometimes I only add operations and not options.