siddhantac / puffin

A beautiful terminal dashboard for hledger 💰
MIT License
256 stars 6 forks source link

--layout option unnecessary? #50

Closed rahji closed 2 months ago

rahji commented 2 months ago

It seems like the --layout option is unnecessary. It only matters because the easily-available version of hledger on ubuntu is a little outdated and doesn't have that option (which causes puffin to break). I made the following change to remove that option and it seems to work as expected.

diff --git a/ui/model.go b/ui/model.go
index a556b73..988da1d 100644
--- a/ui/model.go
+++ b/ui/model.go
@@ -277,7 +277,7 @@ func (m *model) refresh() tea.Cmd {
                accountOpts = accountOpts.WithTree()
        }

-       optsPretty := opts.WithPretty().WithLayout(hledger.LayoutBare).WithAccountDrop(1)
+       optsPretty := opts.WithPretty().WithAccountDrop(1)

        if m.settings.toggleSort {
                optsPretty = optsPretty.WithSortAmount()
siddhantac commented 2 months ago

The --layout bare option is useful when showing multiple currencies. Even when using a single currency, it is useful as the currencies are shown in a single column instead of with every column which saves horizontal space. :)

with layout

> hledger balance type:X -f data/hledger.journal -Y --pretty --layout bare          

Balance changes in 2021-01-01..2022-12-31:

                        ║ Commodity      2021    2022 
════════════════════════╬═════════════════════════════
 expenses:entertainment ║ $                 0   21.98 
 expenses:fitness       ║ $             60.00       0 
 expenses:groceries     ║ $                 0    3.48 
 expenses:household     ║ $            800.00       0 
 expenses:rent          ║ $          2,300.00       0 
 expenses:travel        ║ $                 0   15.05 
 expenses:utilities     ║ $            100.54   99.98 
────────────────────────╫─────────────────────────────
                        ║ $          3,260.54  140.49 

without layout

> hledger balance type:X -f data/hledger.journal -Y --pretty              

Balance changes in 2021-01-01..2022-12-31:

                        ║      2021     2022 
════════════════════════╬════════════════════
 expenses:entertainment ║         0   $21.98 
 expenses:fitness       ║    $60.00        0 
 expenses:groceries     ║         0    $3.48 
 expenses:household     ║   $800.00        0 
 expenses:rent          ║ $2,300.00        0 
 expenses:travel        ║         0   $15.05 
 expenses:utilities     ║   $100.54   $99.98 
────────────────────────╫────────────────────
                        ║ $3,260.54  $140.49 
siddhantac commented 2 months ago

closing due to inactivity