|
@@ -17,6 +17,7 @@
|
|
|
package compose
|
|
|
|
|
|
import (
|
|
|
+ "sort"
|
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
|
@@ -65,3 +66,23 @@ func completeProjectNames(backend api.Service) func(cmd *cobra.Command, args []s
|
|
|
return values, cobra.ShellCompDirectiveNoFileComp
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func completeProfileNames(p *ProjectOptions) validArgsFn {
|
|
|
+ return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
+ project, err := p.ToProject(nil)
|
|
|
+ if err != nil {
|
|
|
+ return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
+ }
|
|
|
+
|
|
|
+ allProfileNames := project.AllServices().GetProfiles()
|
|
|
+ sort.Strings(allProfileNames)
|
|
|
+
|
|
|
+ var values []string
|
|
|
+ for _, profileName := range allProfileNames {
|
|
|
+ if strings.HasPrefix(profileName, toComplete) {
|
|
|
+ values = append(values, profileName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return values, cobra.ShellCompDirectiveNoFileComp
|
|
|
+ }
|
|
|
+}
|