support --period

This commit is contained in:
Bel LaPointe
2024-12-12 21:50:03 -07:00
parent 8ab5a0edf5
commit 62e65c47df
3 changed files with 44 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package cli
import (
"flag"
"fmt"
"log"
"os"
"slices"
@@ -14,7 +15,7 @@ func Main() {
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.Var(&config.Files, "f", "paths to files")
fs.StringVar(&config.Query.Period, "period", "", "period")
fs.Var(&config.Query.Period, "period", "period")
fs.StringVar(&config.Query.Sort, "S", "", "sort ie date")
fs.BoolVar(&config.Query.NoRounding, "no-rounding", false, "no rounding")
fs.IntVar(&config.Query.Depth, "depth", 0, "depth grouping")
@@ -47,8 +48,14 @@ func Main() {
panic(err)
}
if period := config.Query.Period; period != "" {
panic(period)
if period := config.Query.Period; !period.Empty() {
after := period.Start.Format("2006-01-02")
before := period.Stop.Format("2006-01-02")
deltas = deltas.Like(
ledger.LikeAfter(after),
ledger.LikeBefore(before),
)
log.Printf("period=%+v after=%s before=%s", period, after, before)
}
if depth := config.Query.Depth; depth > 0 {