Explorar o código

allow combination of --status and --services

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof %!s(int64=4) %!d(string=hai) anos
pai
achega
7c0e865960
Modificáronse 1 ficheiros con 12 adicións e 12 borrados
  1. 12 12
      cmd/compose/ps.go

+ 12 - 12
cmd/compose/ps.go

@@ -26,13 +26,13 @@ import (
 	"strings"
 
 	"github.com/docker/compose/v2/cmd/formatter"
+	"github.com/docker/compose/v2/pkg/utils"
 
 	formatter2 "github.com/docker/cli/cli/command/formatter"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
 
 	"github.com/docker/compose/v2/pkg/api"
-	"github.com/docker/compose/v2/pkg/utils"
 )
 
 type psOptions struct {
@@ -103,17 +103,6 @@ func runPs(ctx context.Context, backend api.Service, services []string, opts psO
 		return err
 	}
 
-	if opts.Services {
-		services := []string{}
-		for _, s := range containers {
-			if !utils.StringContains(services, s.Service) {
-				services = append(services, s.Service)
-			}
-		}
-		fmt.Println(strings.Join(services, "\n"))
-		return nil
-	}
-
 SERVICES:
 	for _, s := range services {
 		for _, c := range containers {
@@ -139,6 +128,17 @@ SERVICES:
 		return nil
 	}
 
+	if opts.Services {
+		services := []string{}
+		for _, s := range containers {
+			if !utils.StringContains(services, s.Service) {
+				services = append(services, s.Service)
+			}
+		}
+		fmt.Println(strings.Join(services, "\n"))
+		return nil
+	}
+
 	return formatter.Print(containers, opts.Format, os.Stdout,
 		writter(containers),
 		"NAME", "COMMAND", "SERVICE", "STATUS", "PORTS")