left align ints by default again, add -I to right align on request

This commit is contained in:
2026-06-24 09:35:40 +02:00
parent ffcb8adb70
commit 20b79ce168
3 changed files with 11 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ type Table struct {
Entries [][]string
lenHeaders []int
alignInts bool
}
func NewTable(conf *cfg.Config, columns, rows int) *Table {
@@ -45,6 +46,7 @@ func NewTable(conf *cfg.Config, columns, rows int) *Table {
table.Headers = make([]string, columns)
table.Entries = make([][]string, rows)
table.lenHeaders = make([]int, columns)
table.alignInts = conf.AlignInts
return &table
}
@@ -137,7 +139,7 @@ func (data *Table) PrintTSV() error {
for idx, entry := range entries {
length := visibleLen(entry)
if isInt(entry) {
if isInt(entry) && data.alignInts {
// align right
fmt.Print(strings.Repeat(" ", data.lenHeaders[idx]-length), entry)
} else {