NetworkNames offers completion for networks
(dockerCLI APIClientProvider)
| 129 | |
| 130 | // NetworkNames offers completion for networks |
| 131 | func NetworkNames(dockerCLI APIClientProvider) cobra.CompletionFunc { |
| 132 | return Unique(func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 133 | res, err := dockerCLI.Client().NetworkList(cmd.Context(), client.NetworkListOptions{}) |
| 134 | if err != nil { |
| 135 | return nil, cobra.ShellCompDirectiveError |
| 136 | } |
| 137 | var names []string |
| 138 | for _, nw := range res.Items { |
| 139 | names = append(names, nw.Name) |
| 140 | } |
| 141 | return names, cobra.ShellCompDirectiveNoFileComp |
| 142 | }) |
| 143 | } |
| 144 | |
| 145 | // EnvVarNames offers completion for environment-variable names. This |
| 146 | // completion can be used for "--env" and "--build-arg" flags, which |
searching dependent graphs…