MCPcopy
hub / github.com/cli/cli / executeParentHook

Function executeParentHook

pkg/cmdutil/repo_override.go:27–34  ·  view source on GitHub ↗

executeParentHook re-runs the nearest ancestor's persistent pre-run hook, which the hook installed by EnableRepoOverride would otherwise shadow. By default cobra runs only the nearest PersistentPreRunE found walking up from the invoked command, so without this the nearest ancestor hook, such as the

(overrideCmd, cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

25// develop and EnableRepoOverride re-run by hand, and un-suppressing the root
26// gate that agent-task and skills intentionally shadow.
27func executeParentHook(overrideCmd, cmd *cobra.Command, args []string) error {
28 for p := overrideCmd.Parent(); p != nil; p = p.Parent() {
29 if p.PersistentPreRunE != nil {
30 return p.PersistentPreRunE(cmd, args)
31 }
32 }
33 return nil
34}
35
36func EnableRepoOverride(cmd *cobra.Command, f *Factory) {
37 cmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format")

Callers 1

EnableRepoOverrideFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected