You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature: allow running persistent run hooks of all parents
Currently, only one of the persistent pre-runs and post-runs is executed.
It is always the first one found in the parents chain, starting at this command.
Expected behavior is to execute all parents' persistent pre-runs and post-runs.
Dependent projects implemented various workarounds for this:
- manually building persistent hook chains (in every hook).
- applying some kind of monkey-patching on top of Cobra.
This change eliminates the necessity for such workarounds
by allowing to set a global variable EnableTraverseRunHooks.
Tickets:
- spf13#216
- spf13#252
Signed-off-by: Volodymyr Khoroz <[email protected]>
Inside subCmd PersistentPostRun with args: [arg1 arg2]
688
688
```
689
689
690
+
By default, only the first persistent hook found in the command chain is executed.
691
+
That is why in the above output, the `rootCmd PersistentPostRun` was not called for a child command.
692
+
Set `EnableTraverseRunHooks` global variable to `true` if you want to execute all parents' persistent hooks.
693
+
690
694
## Suggestions when "unknown command" happens
691
695
692
696
Cobra will print automatic suggestions when "unknown command" errors happen. This allows Cobra to behave similarly to the `git` command when a typo happens. For example:
0 commit comments