mirror of https://github.com/docker/cli.git
build: change --no-console to --console=[true|false|auto]
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
00792d1704
commit
5a103e1844
|
@ -57,7 +57,7 @@ type buildOptions struct {
|
|||
isolation string
|
||||
quiet bool
|
||||
noCache bool
|
||||
noConsole bool
|
||||
console opts.NullableBool
|
||||
rm bool
|
||||
forceRm bool
|
||||
pull bool
|
||||
|
@ -152,9 +152,9 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
|||
flags.SetAnnotation("stream", "experimental", nil)
|
||||
flags.SetAnnotation("stream", "version", []string{"1.31"})
|
||||
|
||||
flags.BoolVar(&options.noConsole, "no-console", false, "Show non-console output (with buildkit only)")
|
||||
flags.SetAnnotation("no-console", "experimental", nil)
|
||||
flags.SetAnnotation("no-console", "version", []string{"1.38"})
|
||||
flags.Var(&options.console, "console", "Show console output (with buildkit only) (true, false, auto)")
|
||||
flags.SetAnnotation("console", "experimental", nil)
|
||||
flags.SetAnnotation("console", "version", []string{"1.38"})
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,9 @@ func doBuild(ctx context.Context, eg *errgroup.Group, dockerCli command.Cli, opt
|
|||
displayStatus := func(displayCh chan *client.SolveStatus) {
|
||||
var c console.Console
|
||||
out := os.Stderr
|
||||
if cons, err := console.ConsoleFromFile(out); err == nil && !options.noConsole {
|
||||
// TODO: Handle interactive output in non-interactive environment.
|
||||
consoleOpt := options.console.Value()
|
||||
if cons, err := console.ConsoleFromFile(out); err == nil && (consoleOpt == nil || *consoleOpt) {
|
||||
c = cons
|
||||
}
|
||||
// not using shared context to not disrupt display but let is finish reporting errors
|
||||
|
|
36
opts/opts.go
36
opts/opts.go
|
@ -6,6 +6,7 @@ import (
|
|||
"net"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
|
@ -486,3 +487,38 @@ func (m *MemSwapBytes) UnmarshalJSON(s []byte) error {
|
|||
b := MemBytes(*m)
|
||||
return b.UnmarshalJSON(s)
|
||||
}
|
||||
|
||||
// NullableBool is a type for tri-state boolean options
|
||||
type NullableBool struct {
|
||||
b *bool
|
||||
}
|
||||
|
||||
// Type returns the type
|
||||
func (n *NullableBool) Type() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Value returns the value in *bool
|
||||
func (n *NullableBool) Value() *bool {
|
||||
return n.b
|
||||
}
|
||||
|
||||
// Set sets the value. If value is empty string or "auto", nil is set.
|
||||
// Otherwise true or false are set based on flag.Bool behavior.
|
||||
func (n *NullableBool) Set(value string) error {
|
||||
if value != "auto" && value != "" {
|
||||
b, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.b = &b
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NullableBool) String() string {
|
||||
if n.b == nil {
|
||||
return "auto"
|
||||
}
|
||||
return strconv.FormatBool(*n.b)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue