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 {
|
type Config struct {
|
||||||
Files FileList
|
Files FileList
|
||||||
|
BPI string
|
||||||
Query struct {
|
Query struct {
|
||||||
Period Period
|
Period Period
|
||||||
Sort string
|
Sort string
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ func Main() {
|
||||||
fs.BoolVar(&config.Query.Reverse, "r", false, "reverse printed accounts")
|
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.Normalize, "n", false, "normalize with default normalizer")
|
||||||
fs.BoolVar(&config.Query.NoExchanging, "no-exchanging", true, "omit currency exchanges")
|
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 {
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -72,28 +73,31 @@ func Main() {
|
||||||
}
|
}
|
||||||
group := ledger.GroupName(pattern)
|
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 {
|
if config.Query.Normalize {
|
||||||
deltas = ana.NewDefaultNormalizer().Normalize(deltas)
|
deltas = ana.NewDefaultNormalizer().Normalize(deltas)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch cmd[:3] {
|
switch cmd[:3] {
|
||||||
case "bal":
|
case "bal":
|
||||||
/*
|
balances := deltas.Balances().
|
||||||
balances := deltas.Balances()
|
WithBPIs(bpis).
|
||||||
if likePattern != "" {
|
KindaLike(q).
|
||||||
balances = balances.Like(likePattern)
|
KindaGroup(group)
|
||||||
}
|
FPrintBalances(os.Stdout, "", balances, nil)
|
||||||
if notLikePattern != "" {
|
|
||||||
balances = balances.NotLike(notLikePattern)
|
|
||||||
}
|
|
||||||
|
|
||||||
FPrintBalances(os.Stdout, "", balances, nil)
|
|
||||||
*/
|
|
||||||
case "reg":
|
case "reg":
|
||||||
transactions := deltas.Transactions()
|
transactions := deltas.Transactions()
|
||||||
|
|
||||||
for i, transaction := range 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 := false
|
||||||
shouldPrint = shouldPrint || len(balances) > 2
|
shouldPrint = shouldPrint || len(balances) > 2
|
||||||
if config.Query.NoExchanging {
|
if config.Query.NoExchanging {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue