(dockerCli command.Cli, p *ProjectOptions)
| 37 | } |
| 38 | |
| 39 | func completeServiceNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn { |
| 40 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 41 | p.Offline = true |
| 42 | backend, err := compose.NewComposeService(dockerCli) |
| 43 | if err != nil { |
| 44 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 45 | } |
| 46 | |
| 47 | project, _, err := p.ToProject(cmd.Context(), dockerCli, backend, nil) |
| 48 | if err != nil { |
| 49 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 50 | } |
| 51 | var values []string |
| 52 | serviceNames := append(project.ServiceNames(), project.DisabledServiceNames()...) |
| 53 | for _, s := range serviceNames { |
| 54 | if toComplete == "" || strings.HasPrefix(s, toComplete) { |
| 55 | values = append(values, s) |
| 56 | } |
| 57 | } |
| 58 | return values, cobra.ShellCompDirectiveNoFileComp |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func completeProjectNames(dockerCli command.Cli, backendOptions *BackendOptions) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 63 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
no test coverage detected