Hi Jan,
Thank you for raising this.
It looks like you already found how to implement most of the requirements mentioned in the StackOverflow question. That is good!
I am not aware of any issues with combining JShell with Spring, but that could be simply because I never tried this combination.
Thank you for providing a link to a working example, that makes this conversation a lot easier.
I noticed that your repo has picocli-spring-boot-starter as a dependency, that is good.
However, the ApplicationRunner class instantiates the ConnectCommand directly.
To enable Spring dependency injection in the subcommands, please use the SpringPicocliFactory to instantiate the ConnectCommand.
The picocli-spring-boot-starter
README has an example.
In the ConnectCommand#run method, the ShellCommand#main method is invoked.
This in turn means we instantiate the CliCommands object directly without going through Spring.
This is similar, we need to give Spring a chance to do dependency injection here.
One idea is to have an @Inject CliCommands field in ConnectCommand, as well as a @Inject IFactory field,
and pass these to the ShellCommand#main method, so that this method can use these objects to create a CommandLine to start the interactive shell.
I hope this helps,
Remko.