MCPcopy Create free account
hub / github.com/cli/cli / resolveAliasTarget

Function resolveAliasTarget

pkg/cmd/root/help.go:358–372  ·  view source on GitHub ↗

resolveAliasTarget returns the command a user-defined alias expands to, or command unchanged when it is not an alias or the target cannot be resolved. Shell aliases have no target command and are always returned unchanged.

(command *cobra.Command)

Source from the content-addressed store, hash-verified

356// command unchanged when it is not an alias or the target cannot be resolved.
357// Shell aliases have no target command and are always returned unchanged.
358func resolveAliasTarget(command *cobra.Command) *cobra.Command {
359 expansion, ok := command.Annotations[aliasExpansionAnnotation]
360 if !ok {
361 return command
362 }
363 args, err := shlex.Split(expansion)
364 if err != nil || len(args) == 0 {
365 return command
366 }
367 target, _, err := command.Root().Find(args)
368 if err != nil || target == nil {
369 return command
370 }
371 return target
372}

Callers 1

WriteHelpFunction · 0.85

Calls 1

FindMethod · 0.65

Tested by

no test coverage detected