image/tree: Fix table header having escape codes when not tty

When stdout is redirected to a non-tty there should be no ANSI escape
codes emitted.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-11-04 13:08:59 +01:00
parent d5d2ed5baa
commit e5f46499b3
5 changed files with 7 additions and 5 deletions

View File

@ -1,2 +1,2 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1,2 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1,2 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -1,2 +1,2 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

View File

@ -241,6 +241,8 @@ func printImageTree(outs command.Streams, view treeView) {
topNameColor := out.Color(aec.NewBuilder(aec.BlueF, aec.Bold).ANSI)
normalColor := out.Color(tui.ColorSecondary)
untaggedColor := out.Color(tui.ColorTertiary)
titleColor := out.Color(tui.ColorTitle)
isTerm := out.IsTerminal()
out.Println(generateLegend(out, width))
@ -316,7 +318,7 @@ func printImageTree(outs command.Streams, view treeView) {
_, _ = fmt.Fprint(out, strings.Repeat(" ", columnSpacing))
}
_, _ = fmt.Fprint(out, h.Print(tui.ColorTitle, strings.ToUpper(h.Title)))
_, _ = fmt.Fprint(out, h.Print(titleColor, strings.ToUpper(h.Title)))
}
_, _ = fmt.Fprintln(out)