MCPcopy Index your code
hub / github.com/docker/cli / commandAliases

Function commandAliases

cli/cobra.go:245–259  ·  view source on GitHub ↗

commandAliases is a templating function to return aliases for the command, formatted as the full command as they're called (contrary to the default Aliases function, which only returns the subcommand).

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

243// formatted as the full command as they're called (contrary to the default
244// Aliases function, which only returns the subcommand).
245func commandAliases(cmd *cobra.Command) string {
246 if cmd.Annotations["aliases"] != "" {
247 return cmd.Annotations["aliases"]
248 }
249 var parentPath string
250 if cmd.HasParent() {
251 parentPath = cmd.Parent().CommandPath() + " "
252 }
253 var aliases strings.Builder
254 aliases.WriteString(cmd.CommandPath())
255 for _, alias := range cmd.Aliases {
256 aliases.WriteString(", " + parentPath + alias)
257 }
258 return aliases.String()
259}
260
261func topCommands(cmd *cobra.Command) []*cobra.Command {
262 cmds := []*cobra.Command{}

Callers 1

TestCommandAliasesFunction · 0.85

Calls 2

ParentMethod · 0.80
StringMethod · 0.65

Tested by 1

TestCommandAliasesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…