Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitializationException thrown by picocli-codegen on class without direct options #1318

Open
charphi opened this issue Feb 1, 2021 · 4 comments
Labels
theme: annotation-proc An issue or change related to the annotation processor theme: arg-group An issue or change related to argument groups

Comments

@charphi
Copy link
Contributor

charphi commented Feb 1, 2021

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

@remkop
Copy link
Owner

remkop commented Feb 21, 2021

Sorry I have had little time to look into this...

Would the problem be resolved by putting the @ArgGroup annotation on the SpecificOptions class?

@charphi
Copy link
Contributor Author

charphi commented Feb 22, 2021

No problem. It is a low-priority bug.
I'm able to workaround it by adding a dummy hidden option.

@remkop
Copy link
Owner

remkop commented Feb 22, 2021

Can you explain the use case a bit? Why do you want to do this?

@charphi
Copy link
Contributor Author

charphi commented Feb 22, 2021

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.

@remkop remkop added theme: annotation-proc An issue or change related to the annotation processor theme: arg-group An issue or change related to argument groups labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: annotation-proc An issue or change related to the annotation processor theme: arg-group An issue or change related to argument groups
Projects
None yet
Development

No branches or pull requests

2 participants