MCPcopy Create free account
hub / github.com/docker/docker-agent / runParentPreRun

Function runParentPreRun

cmd/root/flags.go:138–148  ·  view source on GitHub ↗

runParentPreRun runs the cobra PersistentPreRunE that should fire before this command's own. It first invokes the directly-captured hook (if any) and otherwise walks up the ancestor chain to find the nearest PersistentPreRunE — which matters when the command is nested more than one level deep (e.g.

(cmd *cobra.Command, captured func(*cobra.Command, []string) error, args []string)

Source from the content-addressed store, hash-verified

136// parent may have no PersistentPreRunE, but a grandparent (such as
137// root) might.
138func runParentPreRun(cmd *cobra.Command, captured func(*cobra.Command, []string) error, args []string) error {
139 if captured != nil {
140 return captured(cmd, args)
141 }
142 for p := cmd.Parent(); p != nil; p = p.Parent() {
143 if p.PersistentPreRunE != nil {
144 return p.PersistentPreRunE(cmd, args)
145 }
146 }
147 return nil
148}
149
150// parseModelShorthand parses "provider/model" into a ModelConfig
151func parseModelShorthand(s string) *latest.ModelConfig {

Callers 1

addGatewayFlagsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected