Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
introduce --quiet option
Browse files Browse the repository at this point in the history
close #1280

Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 16, 2021
1 parent 220b508 commit c74cec9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cli/cmd/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package compose

import (
"context"
"os"

"github.com/spf13/cobra"

Expand All @@ -28,20 +29,29 @@ import (
type buildOptions struct {
*projectOptions
composeOptions
quiet bool
}

func buildCommand(p *projectOptions) *cobra.Command {
opts := buildOptions{
projectOptions: p,
}
buildCmd := &cobra.Command{
cmd := &cobra.Command{
Use: "build [SERVICE...]",
Short: "Build or rebuild services",
RunE: func(cmd *cobra.Command, args []string) error {
if opts.quiet {
devnull, err := os.Open(os.DevNull)
if err != nil {
return err
}
os.Stdout = devnull
}
return runBuild(cmd.Context(), opts, args)
},
}
return buildCmd
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
return cmd
}

func runBuild(ctx context.Context, opts buildOptions, services []string) error {
Expand Down

0 comments on commit c74cec9

Please sign in to comment.