mirror of
https://github.com/docker/compose.git
synced 2025-07-03 11:54:27 +02:00
introduce --quiet option
close #1280 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
220b508d53
commit
c74cec9ae3
@ -18,6 +18,7 @@ package compose
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
@ -28,20 +29,29 @@ import (
|
|||||||
type buildOptions struct {
|
type buildOptions struct {
|
||||||
*projectOptions
|
*projectOptions
|
||||||
composeOptions
|
composeOptions
|
||||||
|
quiet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCommand(p *projectOptions) *cobra.Command {
|
func buildCommand(p *projectOptions) *cobra.Command {
|
||||||
opts := buildOptions{
|
opts := buildOptions{
|
||||||
projectOptions: p,
|
projectOptions: p,
|
||||||
}
|
}
|
||||||
buildCmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "build [SERVICE...]",
|
Use: "build [SERVICE...]",
|
||||||
Short: "Build or rebuild services",
|
Short: "Build or rebuild services",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
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 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 {
|
func runBuild(ctx context.Context, opts buildOptions, services []string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user