vendor: github.com/docker/cli v29.0.1
full diff: https://github.com/docker/cli/compare/v29.0.0...v29.0.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
+2
-2
@@ -28,7 +28,7 @@ func withHeader(header Str) noteOptions {
|
||||
}
|
||||
|
||||
func (o Output) printNoteWithOptions(format string, args []any, opts ...noteOptions) {
|
||||
if o.isTerminal {
|
||||
if !o.noColor {
|
||||
// TODO: Handle all flags
|
||||
format = strings.ReplaceAll(format, "--platform", ColorFlag.Apply("--platform"))
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func (o Output) printNoteWithOptions(format string, args []any, opts ...noteOpti
|
||||
}
|
||||
|
||||
l := line
|
||||
if o.isTerminal {
|
||||
if !o.noColor {
|
||||
l = aec.Italic.Apply(l)
|
||||
}
|
||||
_, _ = fmt.Fprintln(o, l)
|
||||
|
||||
+13
-8
@@ -5,6 +5,7 @@ package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/docker/cli/cli/streams"
|
||||
"github.com/morikuni/aec"
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
|
||||
type Output struct {
|
||||
*streams.Out
|
||||
isTerminal bool
|
||||
noColor bool
|
||||
}
|
||||
|
||||
type terminalPrintable interface {
|
||||
@@ -20,24 +21,28 @@ type terminalPrintable interface {
|
||||
}
|
||||
|
||||
func NewOutput(out *streams.Out) Output {
|
||||
noColor := !out.IsTerminal()
|
||||
if os.Getenv("NO_COLOR") != "" {
|
||||
noColor = true
|
||||
}
|
||||
return Output{
|
||||
Out: out,
|
||||
isTerminal: out.IsTerminal(),
|
||||
Out: out,
|
||||
noColor: noColor,
|
||||
}
|
||||
}
|
||||
|
||||
func (o Output) Color(clr aec.ANSI) aec.ANSI {
|
||||
if o.isTerminal {
|
||||
return clr
|
||||
if o.noColor {
|
||||
return ColorNone
|
||||
}
|
||||
return ColorNone
|
||||
return clr
|
||||
}
|
||||
|
||||
func (o Output) Sprint(all ...any) string {
|
||||
var out []any
|
||||
for _, p := range all {
|
||||
if s, ok := p.(terminalPrintable); ok {
|
||||
out = append(out, s.String(o.isTerminal))
|
||||
out = append(out, s.String(!o.noColor))
|
||||
} else {
|
||||
out = append(out, p)
|
||||
}
|
||||
@@ -47,7 +52,7 @@ func (o Output) Sprint(all ...any) string {
|
||||
|
||||
func (o Output) PrintlnWithColor(clr aec.ANSI, args ...any) {
|
||||
msg := o.Sprint(args...)
|
||||
if o.isTerminal {
|
||||
if !o.noColor {
|
||||
msg = clr.Apply(msg)
|
||||
}
|
||||
_, _ = fmt.Fprintln(o.Out, msg)
|
||||
|
||||
Reference in New Issue
Block a user