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.92k stars 423 forks source link

Leverage Spring boot DI with Picocli #2312

Open gilamarko opened 4 months ago

gilamarko commented 4 months ago

Is there any way that we could have our casual Spring-Boot server up and running and run a picocli class for executing certain actions? E.g spring boot up is Dockerized, there is a com.myapp.CliClass (where I want to be able to inject another spring component) and I run an exec from docker like java -cp myjar.jar com.myapp.CliClass. This mostly works but the issue is that I cannot manage the di work since the command is running in another process not being in the same spring context

remkop commented 3 months ago

Hi @gilamarko have you had a chance to look at this? https://github.com/remkop/picocli/tree/main/picocli-spring-boot-starter