You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Class (command)
- Main.class (main)
-- Sub.class (main sub)
--- Sub$Command1.class (main sub com1)
--- Sub$Command2.class (main sub com2)
All subcommands are declared in the @Command annotation.
When running the AutoComplete command to generate the file we get a stack trace with error:
Cannot instantiate subcommand package.Sub$Command1: the class has no constructor
Caused by: java.lang.NoSuchMethodException:package.Sub$Command1.<init>()
This class has one constructor with parameters annotated with @Inject.
We use our own implementation of IFactory we've passed to the command with --factory.
The Main.class is the command we're trying to generate the autocompletion script for.
It seems like the problem is that the CommandLine implementation that is created by the AutoComplete command does not use the factory passed to it.
-CommandLine commandLine = new CommandLine(instance);+CommandLine commandLine = new CommandLine(instance, factory);
This resolved the issue for us and I will create a pull request for it soon. Let me know if I'm missing any side effects this change may produce that require testing.
The text was updated successfully, but these errors were encountered:
Our structure is as follows:
All subcommands are declared in the
@Command
annotation.When running the AutoComplete command to generate the file we get a stack trace with error:
@Inject
.IFactory
we've passed to the command with--factory
.Main.class
is the command we're trying to generate the autocompletion script for.It seems like the problem is that the
CommandLine
implementation that is created by theAutoComplete
command does not use the factory passed to it.See:
picocli/src/main/java/picocli/AutoComplete.java
Lines 134 to 140 in 82f7c75
I've built picocli locally changing this line:
This resolved the issue for us and I will create a pull request for it soon. Let me know if I'm missing any side effects this change may produce that require testing.
The text was updated successfully, but these errors were encountered: