MCPcopy
hub / github.com/docker/compose / commandName

Function commandName

cmd/cmdtrace/cmd_span.go:130–140  ·  cmd/cmdtrace/cmd_span.go::commandName

commandName returns the path components for a given command, in reverse alphabetical order for consistent usage metrics. The root Compose command and anything before (i.e. "docker") are not included. For example: - docker compose alpha watch -> [watch, alpha] - docker-compose up -> [up]

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

128// - docker compose alpha watch -> [watch, alpha]
129// - docker-compose up -> [up]
130func commandName(cmd *cobra.Command) []string {
131 var name []string
132 for c := cmd; c != nil; c = c.Parent() {
133 if c.Name() == commands.PluginName {
134 break
135 }
136 name = append(name, c.Name())
137 }
138 sort.Sort(sort.Reverse(sort.StringSlice(name)))
139 return name
140}
141
142func getFlags(fs *flag.FlagSet) []string {
143 var result []string

Callers 2

SetupFunction · 0.85
TestCommandNameFunction · 0.85

Calls 1

NameMethod · 0.45

Tested by 1

TestCommandNameFunction · 0.68