I'm working with the Cobra library for Go. The README shows an example that handles configuration setup via the cobra.OnInitialize
function. The documentation for OnInitialize
says:
OnInitialize sets the passed functions to be run when each command's Execute method is called.
But isn't that pretty much exactly the same thing as registering a PersistentPreRun
function on the root command? That will also run just before the Execute
method on any command.