I recently found myself building a couple of CLI applications and just couldn’t bear repeatedly modifying multiple files just to add in a new flag to the command line interface. And what’s worse is that it usually introduced some bugs midway. To tackle this issue, I decided to centralise the entire CLI configuration, and I ended up with this project.
The usage is simple. You define the entire CLI in a single YAML schema, and the code handles the rest. To achieve this, I’ve used reflection and code generation, or go generate
.
Here’s the project: UtkarshVerma/go-cli-boilerplate
I know that there’s already a better framework for doing this, spf13/cobra, but I was unaware of it at the time I started developing this project. It was a mistake on my end, but anyways, this project did teach me a lot so I don’t regret it.