impl cli reg depth
cicd / ci (push) Successful in 1m24s
Details
cicd / ci (push) Successful in 1m24s
Details
parent
a1631019f0
commit
ed0ce83556
|
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
|
||||
)
|
||||
|
|
@ -59,9 +60,15 @@ func Main() {
|
|||
)
|
||||
}
|
||||
|
||||
pattern := ".*"
|
||||
if depth := config.Query.Depth; depth > 0 {
|
||||
panic(depth)
|
||||
pattern = ""
|
||||
for i := 0; i < depth; i++ {
|
||||
pattern += "[^:]*:"
|
||||
}
|
||||
pattern = strings.Trim(pattern, ":")
|
||||
}
|
||||
group := ledger.GroupName(pattern)
|
||||
|
||||
switch cmd[:3] {
|
||||
case "bal":
|
||||
|
|
@ -80,7 +87,7 @@ func Main() {
|
|||
transactions := deltas.Transactions()
|
||||
|
||||
for i, transaction := range transactions {
|
||||
balances := ledger.Deltas(transaction).Like(q).Balances()
|
||||
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances()
|
||||
shouldPrint := false
|
||||
shouldPrint = shouldPrint || len(balances) > 2
|
||||
if config.Query.NoExchanging {
|
||||
|
|
@ -93,7 +100,7 @@ func Main() {
|
|||
}
|
||||
if shouldPrint {
|
||||
fmt.Printf("%s\t%s\n", transaction[0].Date, transaction[0].Description)
|
||||
FPrintBalances(os.Stdout, "\t\t", balances, transactions[:i+1].Deltas().Like(q).Balances())
|
||||
FPrintBalances(os.Stdout, "\t\t", balances, transactions[:i+1].Deltas().Like(q).Group(group).Balances())
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue