(dockerCli command.Cli, p *ProjectOptions)
| 83 | } |
| 84 | |
| 85 | func completeProfileNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn { |
| 86 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 87 | p.Offline = true |
| 88 | backend, err := compose.NewComposeService(dockerCli) |
| 89 | if err != nil { |
| 90 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 91 | } |
| 92 | |
| 93 | project, _, err := p.ToProject(cmd.Context(), dockerCli, backend, nil) |
| 94 | if err != nil { |
| 95 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 96 | } |
| 97 | |
| 98 | allProfileNames := project.AllServices().GetProfiles() |
| 99 | sort.Strings(allProfileNames) |
| 100 | |
| 101 | var values []string |
| 102 | for _, profileName := range allProfileNames { |
| 103 | if strings.HasPrefix(profileName, toComplete) { |
| 104 | values = append(values, profileName) |
| 105 | } |
| 106 | } |
| 107 | return values, cobra.ShellCompDirectiveNoFileComp |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func completeScaleArgs(cli command.Cli, p *ProjectOptions) cobra.CompletionFunc { |
| 112 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
no test coverage detected