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

Function getNaiveFlags

cli-plugins/manager/hooks.go:225–237  ·  view source on GitHub ↗

getNaiveFlags string-matches argv and parses them into a map. This is used when calling hooks after a plugin command, since in this case we can't rely on the cobra command tree to parse flags in this case. In this case, no values are ever passed, since we don't have enough information to process the

(args []string)

Source from the content-addressed store, hash-verified

223// flags in this case. In this case, no values are ever passed,
224// since we don't have enough information to process them.
225func getNaiveFlags(args []string) map[string]string {
226 flags := make(map[string]string)
227 for _, arg := range args {
228 if strings.HasPrefix(arg, "--") {
229 flags[arg[2:]] = ""
230 continue
231 }
232 if strings.HasPrefix(arg, "-") {
233 flags[arg[1:]] = ""
234 }
235 }
236 return flags
237}

Callers 2

TestGetNaiveFlagsFunction · 0.85
RunPluginHooksFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGetNaiveFlagsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…