Skip to content

Commit e5f4649

Browse files
committed
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 <[email protected]>
1 parent d5d2ed5 commit e5f4649

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Info -> U In Use
2-
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
2+
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Info -> U In Use
2-
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
2+
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Info -> U In Use
2-
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
2+
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Info -> U In Use
2-
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
2+
IMAGE ID DISK USAGE CONTENT SIZE EXTRA

cli/command/image/tree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ func printImageTree(outs command.Streams, view treeView) {
241241
topNameColor := out.Color(aec.NewBuilder(aec.BlueF, aec.Bold).ANSI)
242242
normalColor := out.Color(tui.ColorSecondary)
243243
untaggedColor := out.Color(tui.ColorTertiary)
244+
titleColor := out.Color(tui.ColorTitle)
245+
244246
isTerm := out.IsTerminal()
245247

246248
out.Println(generateLegend(out, width))
@@ -316,7 +318,7 @@ func printImageTree(outs command.Streams, view treeView) {
316318
_, _ = fmt.Fprint(out, strings.Repeat(" ", columnSpacing))
317319
}
318320

319-
_, _ = fmt.Fprint(out, h.Print(tui.ColorTitle, strings.ToUpper(h.Title)))
321+
_, _ = fmt.Fprint(out, h.Print(titleColor, strings.ToUpper(h.Title)))
320322
}
321323
_, _ = fmt.Fprintln(out)
322324

0 commit comments

Comments
 (0)