completePid implements shell completion for the `--pid` option of `run` and `create`.
(dockerCLI completion.APIClientProvider)
| 237 | |
| 238 | // completePid implements shell completion for the `--pid` option of `run` and `create`. |
| 239 | func 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. |
searching dependent graphs…