cli supports bal again!
cicd / ci (push) Successful in 1m35s
Details
cicd / ci (push) Successful in 1m35s
Details
parent
30a0414dcd
commit
d093db1a2b
|
|
@ -2,6 +2,7 @@ package cli
|
|||
|
||||
type Config struct {
|
||||
Files FileList
|
||||
BPI string
|
||||
Query struct {
|
||||
Period Period
|
||||
Sort string
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ func Main() {
|
|||
fs.BoolVar(&config.Query.Reverse, "r", false, "reverse printed accounts")
|
||||
fs.BoolVar(&config.Query.Normalize, "n", false, "normalize with default normalizer")
|
||||
fs.BoolVar(&config.Query.NoExchanging, "no-exchanging", true, "omit currency exchanges")
|
||||
fs.StringVar(&config.BPI, "bpi", "", "path to bpi")
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -72,28 +73,31 @@ func Main() {
|
|||
}
|
||||
group := ledger.GroupName(pattern)
|
||||
|
||||
bpis := make(ledger.BPIs)
|
||||
if config.BPI != "" {
|
||||
b, err := ledger.NewBPIs(config.BPI)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
bpis = b
|
||||
}
|
||||
|
||||
if config.Query.Normalize {
|
||||
deltas = ana.NewDefaultNormalizer().Normalize(deltas)
|
||||
}
|
||||
|
||||
switch cmd[:3] {
|
||||
case "bal":
|
||||
/*
|
||||
balances := deltas.Balances()
|
||||
if likePattern != "" {
|
||||
balances = balances.Like(likePattern)
|
||||
}
|
||||
if notLikePattern != "" {
|
||||
balances = balances.NotLike(notLikePattern)
|
||||
}
|
||||
|
||||
FPrintBalances(os.Stdout, "", balances, nil)
|
||||
*/
|
||||
balances := deltas.Balances().
|
||||
WithBPIs(bpis).
|
||||
KindaLike(q).
|
||||
KindaGroup(group)
|
||||
FPrintBalances(os.Stdout, "", balances, nil)
|
||||
case "reg":
|
||||
transactions := deltas.Transactions()
|
||||
|
||||
for i, transaction := range transactions {
|
||||
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances()
|
||||
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances().WithBPIs(bpis)
|
||||
shouldPrint := false
|
||||
shouldPrint = shouldPrint || len(balances) > 2
|
||||
if config.Query.NoExchanging {
|
||||
|
|
|
|||
Loading…
Reference in New Issue