{"modulePath":"github.com/docker/CLI","version":"v29.10.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package completion\n\n## Functions\n\n```go\nfunc ContainerNames(dockerCLI APIClientProvider, all bool, filters ...func(container.Summary) bool) cobra.CompletionFunc\n```\nContainerNames offers completion for container names and IDs By default, only names are returned. Set DOCKER\\_COMPLETION\\_SHOW\\_CONTAINER\\_IDS=yes to also complete IDs.\n\n```go\nfunc EnvVarNames() cobra.CompletionFunc\n```\nEnvVarNames 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 not their value. This also prevents the completion script from printing values of environment variables containing sensitive values.\n\nFor example;\n\n\texport MY_VAR=hello\n\tdocker run --rm --env MY_VAR alpine printenv MY_VAR\n\thello\n\n```go\nfunc FileNames() cobra.CompletionFunc\n```\nFileNames is a convenience function to use [cobra.ShellCompDirectiveDefault](/github.com/spf13/cobra#ShellCompDirectiveDefault), which indicates to let the shell perform its default behavior after completions have been provided.\n\n```go\nfunc FromList(options ...string) cobra.CompletionFunc\n```\nFromList offers completion for the given list of options.\n\n```go\nfunc ImageNames(dockerCLI APIClientProvider, limit int) cobra.CompletionFunc\n```\nImageNames offers completion for images present within the local store\n\n```go\nfunc ImageNamesWithBase(dockerCLI APIClientProvider, limit int) cobra.CompletionFunc\n```\nImageNamesWithBase offers completion for images present within the local store, including both full image names with tags and base image names (repository names only) when multiple tags exist for the same base name\n\n```go\nfunc NetworkNames(dockerCLI APIClientProvider) cobra.CompletionFunc\n```\nNetworkNames offers completion for networks\n\n```go\nfunc Platforms() cobra.CompletionFunc\n```\nPlatforms offers completion for platform-strings. It provides a non-exhaustive list of platforms to be used for completion. Platform-strings are based on [runtime.GOOS](/runtime#GOOS) and [runtime.GOARCH](/runtime#GOARCH), but with (optional) variants added. A list of recognised os/arch combinations from the Go runtime can be obtained through \"go tool dist list\".\n\nSome noteworthy exclusions from this list:\n\n  - arm64 images (\"windows/arm64\", \"windows/arm64/v8\") do not yet exist for windows.\n  - we don't (yet) include \\`os-variant\\` for completion (as can be used for Windows images)\n  - we don't (yet) include platforms for which we don't build binaries, such as BSD platforms (freebsd, netbsd, openbsd), android, macOS (darwin).\n  - we currently exclude architectures that may have unofficial builds, but don't have wide adoption (and no support), such as loong64, mipsXXX, ppc64 (non-le) to prevent confusion.\n\n```go\nfunc Unique(fn cobra.CompletionFunc) cobra.CompletionFunc\n```\nUnique wraps a completion func and removes completion results that are already consumed (i.e., appear in \"args\").\n\nFor example:\n\n\t# initial completion: args is empty, so all results are shown\n\tcommand \u003ctab\u003e\n\tone two three\n\n\t# \"one\" is already used so omitted\n\tcommand one \u003ctab\u003e\n\ttwo three\n\n```go\nfunc VolumeNames(dockerCLI APIClientProvider) cobra.CompletionFunc\n```\nVolumeNames offers completion for volumes\n\n```go\nfunc WithPrefix(prefix string, values []string) []string\n```\nWithPrefix prefixes every element in the slice with the given prefix. It is a helper for building \"--filter\" completions, where each candidate value is offered as \"key=value\".\n\n```go\nfunc WithSuffix(suffix string, values []string) []string\n```\nWithSuffix appends the given suffix to every element in the slice. It is a helper for building \"--filter\" completions, where filter keys are offered with a trailing \"=\" (combined with [cobra.ShellCompDirectiveNoSpace](/github.com/spf13/cobra#ShellCompDirectiveNoSpace)).\n\n## Types\n\n```go\ntype APIClientProvider interface {\n\tClient() client.APIClient\n}\n```\nAPIClientProvider provides a method to get a [client.APIClient](/github.com/moby/moby/client#APIClient), initializing it if needed.\n\nIt's a smaller interface than \\[command.Cli], and used in situations where an APIClient is needed, but we want to postpone initializing the client until it's used.\n\n","path":"github.com/docker/CLI/cli/command/completion","name":"completion","synopsis":"","isRedistributable":true}
