@@ -20,6 +20,7 @@ var projectName string
2020
2121var dockerClient client.APIClient
2222var apiService api.Compose
23+ var mgr * manager.Manager
2324
2425func main () {
2526 for _ , fn := range []func () error {
@@ -39,7 +40,8 @@ func initCobra() error {
3940 root .PersistentFlags ().StringVarP (& projectName , "name" , "n" , "" , "Project name" )
4041
4142 _ = root .RegisterFlagCompletionFunc ("name" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
42- return manager .ListProjects (toComplete ), cobra .ShellCompDirectiveNoFileComp
43+ projects , _ := mgr .List (toComplete )
44+ return projects , cobra .ShellCompDirectiveNoFileComp
4345 })
4446
4547 return root .Execute ()
@@ -60,14 +62,16 @@ func initDocker() error {
6062
6163 apiService = compose .NewComposeService (dockerCLI )
6264
65+ mgr = manager .New ()
66+
6367 return nil
6468}
6569
6670func validArgsWrapper (f func (ctx context.Context , cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective )) func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
6771 return func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
6872 ctx := context .Background ()
6973
70- _ , err := manager .AutodetectProject (projectName )
74+ _ , err := mgr .AutodetectProject (ctx , projectName )
7175
7276 if err != nil && ! cmd .Flags ().Changed ("name" ) { // not auto-detected and name is not even mentioned
7377 return []string {"--name" }, cobra .ShellCompDirectiveNoFileComp
0 commit comments