
Show HN: Generate cli code in Go using static analysis - buchanae
https://github.com/buchanae/cli
======
buchanae
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.

Thanks in advance for any feedback!

