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
1 changed files with 8 additions and 3 deletions

View File

@ -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)
})