cobra's PersistentPreRun's are designed such that each new one overrides
all parent ones.
We're using a PersistentPreRun to setup logging though, and clearly want
that to cascade all the way.
This adds a small helper function so each override is done by pushing a
new function onto a stack rather than by replacing the previous one.
Based on the rocket subcommand handling code with some tweaks:
- Use the default flag set so global flags work normally.
- Allow global flags both before and after the subcommand.
- Generalize a little so multiple cli utilities can be implemented.