diff --git a/cmd/ilm-ls.go b/cmd/ilm-ls.go index a437ea38..f5a689b5 100644 --- a/cmd/ilm-ls.go +++ b/cmd/ilm-ls.go @@ -116,8 +116,10 @@ func (i ilmListMessage) String() string { tbl = newPrettyTable(tableSeperator, fields...) tblContents = getILMHeader(&tbl, alignedHdrLabels...) - // Reuse the fields - fields = nil + // If no data to show at all, quit here + if len(cellDataNoTags) == 0 && len(cellDataWithTags) == 0 { + return tblContents + } // The data table var tblRowField *[]string @@ -127,6 +129,9 @@ func (i ilmListMessage) String() string { tblRowField = &cellDataNoTags[0] } + // Reuse the fields + fields = nil + for _, hdr := range *tblRowField { fields = append(fields, Field{ilmThemeRow, len(hdr)}) }