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

Function completePid

cli/command/container/completion.go:239–250  ·  view source on GitHub ↗

completePid implements shell completion for the `--pid` option of `run` and `create`.

(dockerCLI completion.APIClientProvider)

Source from the content-addressed store, hash-verified

237
238// completePid implements shell completion for the `--pid` option of `run` and `create`.
239func completePid(dockerCLI completion.APIClientProvider) cobra.CompletionFunc {
240 return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
241 if len(toComplete) > 0 && strings.HasPrefix("container", toComplete) { //nolint:gocritic // not swapped, matches partly typed "container"
242 return []string{"container:"}, cobra.ShellCompDirectiveNoSpace
243 }
244 if strings.HasPrefix(toComplete, "container:") {
245 names, _ := completion.ContainerNames(dockerCLI, true)(cmd, args, toComplete)
246 return prefixWith("container:", names), cobra.ShellCompDirectiveNoFileComp
247 }
248 return []string{"container:", "host"}, cobra.ShellCompDirectiveNoFileComp
249 }
250}
251
252// completeSecurityOpt implements shell completion for the `--security-opt` option of `run` and `create`.
253// The completion is partly composite.

Callers 2

addCompletionsFunction · 0.85
TestCompletePidFunction · 0.85

Calls 1

prefixWithFunction · 0.70

Tested by 1

TestCompletePidFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…