A Quarkus Command Line Application
Most people know Quarkus as a great way to build fast, scalable microservices. What many may not be aware of, however, is that Quarkus can also be used to build command line applications as well. In this post, we’ll take a look at how we can leverage the Quarkus ecosystem we already know to build a command line utility quickly and easily.
Writing CLIs with Spring Boot and JCommander
I was recently asked to convert a Spring Boot-based "CLI" to a real CLI utility. It was actually just a normal Spring Boot application with REST endpoints that we’d hit with curl. Pretty ugly. After a few frustrating hours, I finally settled on a solution that seems to work pretty well for us. It uses Spring Boot, of course, as that’s our library of choice, plus JCommander for the argument handling. This is a pared-down example of how the application is structured. And because I care about of each you deeply, I’ll present it in Java AND Kotlin. :)
For those of you in a hurry, you can get the complete code in my GitHub repo. Everyone else, feel free to read along.
CLI Libraries Compared
I recently ran across a couple of pretty cool libraries for creating command-line tools: Airline from the Airlift project, and crest from Tomitribe. Having spent the last few years working on administration for GlassFish, this is an area near and dear to my heart, so I thought I’d cobble together a quick example using each to see how usable they are.