I’ve been creating CLI applications (the beardy admin says „scripts“) for a while now in various languages and settled in Python for the last years. Sadly however, in my company there seem to be only so many people, that develop in Python. So I had to leave Python behind and needed something else.
But Java… as a CLI-only application? While Java is good for a large software platform where many people develop simultaneously, it is hell for short one-task-scripts, that have to be ready in a few hours.
When I was using Python as a CLI language, I found Cement to be quite good. It’s a CLI-framework, that
„Wait, ‚uses a template language‘?“ Yes. And that’s quite an interesting fact, because why should modern CLI-scripts should be less „well-written“ than usual applications? Because they need to written in a short period of time? That’s no excuse! Why not invest a thought in a MVC-approach and separate the command line in- and output (view) from the logic (controller) and even an API or backend (model)? Once you think of it, it’s a quite cool feature. And while you’re at it, write unit and integration tests for your API and commands!
That’s already quite a bit. What about the missing pieces?
If you’d like to try it: I’ve created a grunt-init template, that you can use to get these features (note: nconf isn’t implemented in that template yet). Download it from its repository and put it in ~/.grunt-init. Afterwards just run
in an empty directory. Check out the Readme for more information.