浏览代码

introduce pull --quiet option

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 4 年之前
父节点
当前提交
a2d335271a
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      cli/cmd/compose/pull.go

+ 8 - 3
cli/cmd/compose/pull.go

@@ -18,7 +18,6 @@ package compose
 
 import (
 	"context"
-
 	"github.com/spf13/cobra"
 
 	"github.com/docker/compose-cli/api/client"
@@ -28,20 +27,22 @@ import (
 type pullOptions struct {
 	*projectOptions
 	composeOptions
+	quiet bool
 }
 
 func pullCommand(p *projectOptions) *cobra.Command {
 	opts := pullOptions{
 		projectOptions: p,
 	}
-	pullCmd := &cobra.Command{
+	cmd := &cobra.Command{
 		Use:   "pull [SERVICE...]",
 		Short: "Pull service images",
 		RunE: func(cmd *cobra.Command, args []string) error {
 			return runPull(cmd.Context(), opts, args)
 		},
 	}
-	return pullCmd
+	cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information")
+	return cmd
 }
 
 func runPull(ctx context.Context, opts pullOptions, services []string) error {
@@ -55,6 +56,10 @@ func runPull(ctx context.Context, opts pullOptions, services []string) error {
 		return err
 	}
 
+	if opts.quiet {
+		return c.ComposeService().Pull(ctx, project)
+	}
+
 	_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
 		return "", c.ComposeService().Pull(ctx, project)
 	})