Skip to content

Commit 733647d

Browse files
committed
Fix products ls default output
1 parent b513169 commit 733647d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cmd/products/products.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ func printFormatted(products []shopify.Product, fieldsToPrint []string) {
7171
s := reflect.ValueOf(&product).Elem()
7272

7373
for i := 0; i < s.NumField(); i++ {
74-
field := normalizeField(s.Type().Field(i).Name)
75-
76-
if isFieldToPrint(field, normalizedFieldsToPrint) {
77-
t.AddLine(s.Type().Field(i).Name, s.Field(i).Interface())
74+
field := s.Type().Field(i).Name
75+
normalizedField := normalizeField(field)
76+
77+
if len(fieldsToPrint) > 0 {
78+
if isFieldToPrint(normalizedField, normalizedFieldsToPrint) {
79+
t.AddLine(field, s.Field(i).Interface())
80+
}
81+
} else {
82+
t.AddLine(field, s.Field(i).Interface())
7883
}
7984
}
8085

0 commit comments

Comments
 (0)