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

Function completeServiceNames

cmd/compose/completion.go:39–60  ·  cmd/compose/completion.go::completeServiceNames
(dockerCli command.Cli, p *ProjectOptions)

Source from the content-addressed store, hash-verified

37}
38
39func 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
62func 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) {

Callers 15

logsCommandFunction · 0.85
copyCommandFunction · 0.85
pushCommandFunction · 0.85
stopCommandFunction · 0.85
exportCommandFunction · 0.85
topCommandFunction · 0.85
startCommandFunction · 0.85
attachCommandFunction · 0.85
upCommandFunction · 0.85
restartCommandFunction · 0.85
removeCommandFunction · 0.85
pullCommandFunction · 0.85

Calls 2

NewComposeServiceFunction · 0.92
ToProjectMethod · 0.45

Tested by

no test coverage detected