diff --git a/internal/control/cli/controller.go b/internal/control/cli/controller.go index 261c8c26..dcc89034 100644 --- a/internal/control/cli/controller.go +++ b/internal/control/cli/controller.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/ja-he/dayplan/internal/control" @@ -57,6 +58,8 @@ type Controller struct { // TODO: try to get rid of this ensureEventsPaneTimestampWithinVisibleScroll func(time.Time) + + log zerolog.Logger } // NewController creates a new Controller. @@ -66,7 +69,10 @@ func NewController( categoryStyling styling.CategoryStyling, stylesheet styling.Stylesheet, ) (*Controller, error) { - controller := Controller{} + controller := Controller{ + log: log.With().Str("component", "controller").Logger(), + } + defer controller.goToDay(date) categoryGetter := func(name string) model.Category { cat, ok := categoryStyling.GetKnownCategoriesByName()[name] @@ -85,7 +91,6 @@ func NewController( var err error dp, err = providers.NewFilesDataProvider( path.Join(envData.BaseDirPath, "days"), - controller.data.Categories, ) if err != nil { return nil, fmt.Errorf("cannot initialize data provider (%w)", err) diff --git a/internal/control/cli/summarize.go b/internal/control/cli/summarize.go index 2ac7957d..a289fb4e 100644 --- a/internal/control/cli/summarize.go +++ b/internal/control/cli/summarize.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "log" "os" "path" "strings" @@ -11,6 +10,7 @@ import ( "github.com/ja-he/dayplan/internal/config" "github.com/ja-he/dayplan/internal/control" "github.com/ja-he/dayplan/internal/model" + "github.com/ja-he/dayplan/internal/storage" "github.com/ja-he/dayplan/internal/storage/providers" "github.com/ja-he/dayplan/internal/styling" ) @@ -18,8 +18,8 @@ import ( // Flags for the `summarize` command line command, for `go-flags` to parse // command line args into. type SummarizeCommand struct { - FromDay string `short:"f" long:"from" description:"the day from which to start summarizing" value-name:"" required:"true"` - TilDay string `short:"t" long:"til" description:"the day til which to summarize (inclusive)" value-name:"" required:"true"` + From time.Time `short:"f" long:"from" description:"the timestamp from which to start summarizing" value-name:"