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

Function EnvVarNames

cli/command/completion/functions.go:158–168  ·  view source on GitHub ↗

EnvVarNames offers completion for environment-variable names. This completion can be used for "--env" and "--build-arg" flags, which allow obtaining the value of the given environment-variable if present in the local environment, so we only should complete the names of the environment variables, and

()

Source from the content-addressed store, hash-verified

156// docker run --rm --env MY_VAR alpine printenv MY_VAR
157// hello
158func EnvVarNames() cobra.CompletionFunc {
159 return Unique(func(_ *cobra.Command, _ []string, _ string) (names []string, _ cobra.ShellCompDirective) {
160 envs := os.Environ()
161 names = make([]string, 0, len(envs))
162 for _, env := range envs {
163 name, _, _ := strings.Cut(env, "=")
164 names = append(names, name)
165 }
166 return names, cobra.ShellCompDirectiveNoFileComp
167 })
168}
169
170// FromList offers completion for the given list of options.
171func FromList(options ...string) cobra.CompletionFunc {

Callers 1

TestCompleteEnvVarNamesFunction · 0.85

Calls 1

UniqueFunction · 0.85

Tested by 1

TestCompleteEnvVarNamesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…