Essentially, you can write CLI code using functions and struct types following a certain convention, and then use these tools to generate code for flags, env vars, config files, subcommands, etc.
func AddTask(opt Opt, path string)
...will be turned into a CLI command "add task" where all the fields of "Opt" can be set via flags/env/yaml, and the positional args are mapped in too. Default values are taken from "DefaultOpt()", if it exists.
I've written a number of Go apps now, and I always feel like CLI + config is a struggle. This is my latest attempt to distill all that experience into something I can reuse. It's still rough around the edges, but the armature is there now. Hopefully you can get a feel for what it is and where it's headed. There's still a long list of additions and cleanups I want to make.
1 comment
[ 2.8 ms ] story [ 9.2 ms ] threadI've written a number of Go apps now, and I always feel like CLI + config is a struggle. This is my latest attempt to distill all that experience into something I can reuse. It's still rough around the edges, but the armature is there now. Hopefully you can get a feel for what it is and where it's headed. There's still a long list of additions and cleanups I want to make.
Thanks in advance for any feedback!