MCPcopy
hub / github.com/docker/compose / completeProfileNames

Function completeProfileNames

cmd/compose/completion.go:85–109  ·  view source on GitHub ↗
(dockerCli command.Cli, p *ProjectOptions)

Source from the content-addressed store, hash-verified

83}
84
85func 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
111func completeScaleArgs(cli command.Cli, p *ProjectOptions) cobra.CompletionFunc {
112 return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

Callers 1

RootCommandFunction · 0.85

Calls 2

NewComposeServiceFunction · 0.92
ToProjectMethod · 0.45

Tested by

no test coverage detected