Skip to content

Commit 35bd4ad

Browse files
committed
Always hide identical arch column any width
Signed-off-by: Anders F Björklund <[email protected]>
1 parent facac65 commit 35bd4ad

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/store/instance.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ func PrintInstances(w io.Writer, instances []*Instance, format string, options *
270270
if !hideType {
271271
columns++ // VMTYPE
272272
}
273-
if width != 0 && (columns+6)*8 > width && !all {
274-
hideArch = len(archs) == 1
275-
}
273+
hideArch = len(archs) == 1 && !all
276274
if !hideArch {
277275
columns++ // ARCH
278276
}

pkg/store/instance_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ var instance = Instance{
1818
Dir: "dir",
1919
}
2020

21-
var table = "NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR\n" +
22-
"foo Stopped 127.0.0.1:0 qemu x86_64 0 0B 0B dir\n"
21+
var table = "NAME STATUS SSH VMTYPE CPUS MEMORY DISK DIR\n" +
22+
"foo Stopped 127.0.0.1:0 qemu 0 0B 0B dir\n"
2323

2424
// for width 60, everything is hidden
2525
var table60 = "NAME STATUS SSH CPUS MEMORY DISK\n" +
@@ -29,15 +29,19 @@ var table60 = "NAME STATUS SSH CPUS MEMORY DISK\n" +
2929
var table80 = "NAME STATUS SSH CPUS MEMORY DISK DIR\n" +
3030
"foo Stopped 127.0.0.1:0 0 0B 0B dir\n"
3131

32+
// for width 100 (or with all), nothing is hidden
33+
var tableAll = "NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR\n" +
34+
"foo Stopped 127.0.0.1:0 qemu x86_64 0 0B 0B dir\n"
35+
3236
// for width 80, directory is hidden (if not identical)
3337
var tableTwo = "NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK\n" +
3438
"foo Stopped 127.0.0.1:0 qemu x86_64 0 0B 0B\n" +
3539
"bar Stopped 127.0.0.1:0 vz aarch64 0 0B 0B\n"
3640

3741
const separator = string(filepath.Separator)
3842

39-
var tableHome = "NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR\n" +
40-
"foo Stopped 127.0.0.1:0 qemu x86_64 0 0B 0B ~" + separator + "dir\n"
43+
var tableHome = "NAME STATUS SSH VMTYPE CPUS MEMORY DISK DIR\n" +
44+
"foo Stopped 127.0.0.1:0 qemu 0 0B 0B ~" + separator + "dir\n"
4145

4246
func TestPrintInstanceTable(t *testing.T) {
4347
var buf bytes.Buffer
@@ -75,7 +79,7 @@ func TestPrintInstanceTableAll(t *testing.T) {
7579
instances := []*Instance{&instance}
7680
options := PrintOptions{TerminalWidth: 40, AllFields: true}
7781
PrintInstances(&buf, instances, "table", &options)
78-
assert.Equal(t, buf.String(), table)
82+
assert.Equal(t, buf.String(), tableAll)
7983
}
8084

8185
func TestPrintInstanceTableTwo(t *testing.T) {

0 commit comments

Comments
 (0)