add table.AddRowLate() to add rows after sorting

This commit is contained in:
2026-07-08 14:57:46 +02:00
parent 76ad6c7afa
commit 99bf703997

View File

@@ -206,6 +206,22 @@ func (table *Table) AddRow(fields ...any) {
table.Entries = append(table.Entries, fields) table.Entries = append(table.Entries, fields)
} }
func (table *Table) AddRowLate(fields ...any) {
table.AddRow(fields)
if !table.processed {
return
}
row := make([]string, len(fields))
for idx, field := range fields {
row[idx] = any2string(field)
}
table.rows = append(table.rows, row)
}
// needed for json and yaml output // needed for json and yaml output
func (table *Table) toMap() []map[string]any { func (table *Table) toMap() []map[string]any {
raw := make([]map[string]any, len(table.Entries)) raw := make([]map[string]any, len(table.Entries))