MCPcopy Create free account
hub / github.com/ddev/ddev / addCommandIfNotExists

Function addCommandIfNotExists

cmd/ddev/cmd/root.go:231–238  ·  view source on GitHub ↗

addCommandIfNotExists adds cmdToAdd to rootCmd if a command with the same name does not already exist.

(rootCmd *cobra.Command, cmdToAdd *cobra.Command)

Source from the content-addressed store, hash-verified

229
230// addCommandIfNotExists adds cmdToAdd to rootCmd if a command with the same name does not already exist.
231func addCommandIfNotExists(rootCmd *cobra.Command, cmdToAdd *cobra.Command) {
232 for _, existingCmd := range rootCmd.Commands() {
233 if existingCmd.Name() == cmdToAdd.Name() {
234 return
235 }
236 }
237 rootCmd.AddCommand(cmdToAdd)
238}

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected