Yeah, I think I will try the simpler approach. I generally just have stuff like
tool [-debug] [-store sqlite] cmd [-opt] [arg]
So, main needs to bootstraps logger and store and then delegate to downstream commands that almost always will consume the store and logger.
I'm currently using PersistentPreRunE to bootstrap the logging and store.. but I'm not really happy with the end result and some things are awkward. Maybe it would be less awkward if cobra had a 'Context' I could stick things in. The last issue was I added a version subcommand, which kept creating the store. I ended up having to do
I'm currently using PersistentPreRunE to bootstrap the logging and store.. but I'm not really happy with the end result and some things are awkward. Maybe it would be less awkward if cobra had a 'Context' I could stick things in. The last issue was I added a version subcommand, which kept creating the store. I ended up having to do
Which would have been a lot simpler if I was doing things manually.