howeyc / ledger

Command line double-entry accounting program
https://howeyc.github.io/ledger/
ISC License
455 stars 43 forks source link

balance panic #36

Closed porjo closed 2 years ago

porjo commented 2 years ago

Balance panics when columns is set too small. Could it instead work out the minimum columns required for the given display and reset columns to that? And perhaps also output to stderr a message e.g. 'columns 40 is too small, resetting to 45'

ledger balance -f ../data/ledger.ledger --columns 40
panic: strings: negative Repeat count

goroutine 1 [running]:
strings.Repeat({0xa23b08?, 0x23?}, 0x8ce0b4?)
    /usr/lib/golang/src/strings/strings.go:533 +0x4d8
github.com/howeyc/ledger/ledger/cmd.PrintBalances({0xc000100780, 0x4c, 0x32?}, 0x0, 0xffffffffffffffff, 0x28)
    /home/ian/ledger/ledger.git/ledger/cmd/print.go:112 +0x195
github.com/howeyc/ledger/ledger/cmd.glob..func5(0xd22120?, {0xc000071880, 0x0, 0x4})
    /home/ian/ledger/ledger.git/ledger/cmd/printBalance.go:24 +0xff
[...]
porjo commented 2 years ago

Having an option to automatically output using minimum number of columns would be a handy feature on devices with constrained widths e.g. mobile - perhaps if columns were set to 0 it could do this?