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
|
isolation string
|
||||||
quiet bool
|
quiet bool
|
||||||
noCache bool
|
noCache bool
|
||||||
noConsole bool
|
console opts.NullableBool
|
||||||
rm bool
|
rm bool
|
||||||
forceRm bool
|
forceRm bool
|
||||||
pull bool
|
pull bool
|
||||||
|
@ -152,9 +152,9 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
flags.SetAnnotation("stream", "experimental", nil)
|
flags.SetAnnotation("stream", "experimental", nil)
|
||||||
flags.SetAnnotation("stream", "version", []string{"1.31"})
|
flags.SetAnnotation("stream", "version", []string{"1.31"})
|
||||||
|
|
||||||
flags.BoolVar(&options.noConsole, "no-console", false, "Show non-console output (with buildkit only)")
|
flags.Var(&options.console, "console", "Show console output (with buildkit only) (true, false, auto)")
|
||||||
flags.SetAnnotation("no-console", "experimental", nil)
|
flags.SetAnnotation("console", "experimental", nil)
|
||||||
flags.SetAnnotation("no-console", "version", []string{"1.38"})
|
flags.SetAnnotation("console", "version", []string{"1.38"})
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,9 @@ func doBuild(ctx context.Context, eg *errgroup.Group, dockerCli command.Cli, opt
|
||||||
displayStatus := func(displayCh chan *client.SolveStatus) {
|
displayStatus := func(displayCh chan *client.SolveStatus) {
|
||||||
var c console.Console
|
var c console.Console
|
||||||
out := os.Stderr
|
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
|
c = cons
|
||||||
}
|
}
|
||||||
// not using shared context to not disrupt display but let is finish reporting errors
|
// 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"
|
"net"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
@ -486,3 +487,38 @@ func (m *MemSwapBytes) UnmarshalJSON(s []byte) error {
|
||||||
b := MemBytes(*m)
|
b := MemBytes(*m)
|
||||||
return b.UnmarshalJSON(s)
|
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