introduce pull --quiet option

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-02-16 14:01:56 +01:00
parent da7498949e
commit a2d335271a

View File

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