Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Info -> U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
45 changes: 24 additions & 21 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ func printImageTree(outs command.Streams, view treeView) {
}

out := tui.NewOutput(outs.Out())
isTerm := out.IsTerminal()

_, width := out.GetTtySize()
if width == 0 {
width = 80
}
if width < 20 {
limitWidth := width == 0
if isTerm && width < 20 {
width = 20
}

Expand All @@ -243,9 +243,10 @@ func printImageTree(outs command.Streams, view treeView) {
untaggedColor := out.Color(tui.ColorTertiary)
titleColor := out.Color(tui.ColorTitle)

isTerm := out.IsTerminal()

out.Println(generateLegend(out, width))
// Legend is right-aligned, so don't print it if the width is unlimited
if !limitWidth {
out.Println(generateLegend(out, width))
}

possibleChips := getPossibleChips(view)
columns := []imgColumn{
Expand Down Expand Up @@ -340,25 +341,27 @@ func printImageTree(outs command.Streams, view treeView) {
// to display their content.
func adjustColumns(width uint, columns []imgColumn, images []topImage) []imgColumn {
nameWidth := int(width)
for idx, h := range columns {
if h.Width == 0 {
continue
}
d := h.Width
if idx > 0 {
d += columnSpacing
}
// If the first column gets too short, remove remaining columns
if nameWidth-d < 12 {
columns = columns[:idx]
break
if nameWidth > 0 {
for idx, h := range columns {
if h.Width == 0 {
continue
}
d := h.Width
if idx > 0 {
d += columnSpacing
}
// If the first column gets too short, remove remaining columns
if nameWidth-d < 12 {
columns = columns[:idx]
break
}
nameWidth -= d
}
nameWidth -= d
}

// Try to make the first column as narrow as possible
widest := widestFirstColumnValue(columns, images)
if nameWidth > widest {
if width == 0 || nameWidth > widest {
nameWidth = widest
}
columns[0].Width = nameWidth
Expand Down
Loading