MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / findCommand

Function findCommand

app/cli/cmd/plugins.go:289–307  ·  view source on GitHub ↗

findCommand recursively searches for a command by name in the command tree

(rootCmd *cobra.Command, name string)

Source from the content-addressed store, hash-verified

287
288// findCommand recursively searches for a command by name in the command tree
289func findCommand(rootCmd *cobra.Command, name string) *cobra.Command {
290 // Check if the root command itself matches
291 if rootCmd.Name() == name {
292 return rootCmd
293 }
294
295 // Search through all subcommands recursively
296 for _, cmd := range rootCmd.Commands() {
297 if cmd.Name() == name {
298 return cmd
299 }
300 // Recursively search in subcommands
301 if found := findCommand(cmd, name); found != nil {
302 return found
303 }
304 }
305
306 return nil
307}
308
309// loadAllPlugins loads all plugins and registers their commands to the root command
310func loadAllPlugins(rootCmd *cobra.Command) error {

Callers 1

loadAllPluginsFunction · 0.85

Calls 1

NameMethod · 0.45

Tested by

no test coverage detected