Skip to content

Commit

Permalink
Merge pull request #42 from ja-he/feat-backlog-tasks-view
Browse files Browse the repository at this point in the history
Add a view for a backlog of tasks/events
  • Loading branch information
ja-he authored Nov 26, 2023
2 parents e9412b4 + 9fc6fec commit 08b6be2
Show file tree
Hide file tree
Showing 48 changed files with 3,029 additions and 889 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: fmt
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
Expand Down
13 changes: 13 additions & 0 deletions internal/control/action/simple.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package action

import "github.com/rs/zerolog/log"

// Simple implements the Action interface.
// It models a simple, non-undoable action as a func() which is called on Do.
type Simple struct {
Expand All @@ -10,6 +12,17 @@ type Simple struct {
// Do performs this simple action.
// A simple action is not undoable.
func (a *Simple) Do() {
if a.action == nil { // NOTE: this check is pointless for how I am using these...
explanation := func() string {
if a.explain == nil {
return "no explanation available"
}
return a.explain()
}()
log.Warn().Msgf("Simple action '%s' has no action function (is nil)", explanation)
return
}

a.action()
}

Expand Down
8 changes: 4 additions & 4 deletions internal/control/cli/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/ja-he/dayplan/internal/config"
"github.com/ja-he/dayplan/internal/control"
"github.com/ja-he/dayplan/internal/filehandling"
"github.com/ja-he/dayplan/internal/model"
"github.com/ja-he/dayplan/internal/storage"
)

// AddCommand contains flags for the `summarize` command line command, for
Expand Down Expand Up @@ -88,13 +88,13 @@ func (command *AddCommand) Execute(args []string) error {
}

type fileAndDay struct {
file *filehandling.FileHandler
file *storage.FileHandler
data *model.Day
date model.Date
}
toWrite := []fileAndDay{}

startDayFile := filehandling.NewFileHandler(envData.BaseDirPath + "/days/" + date.ToString())
startDayFile := storage.NewFileHandler(envData.BaseDirPath + "/days/" + date.ToString())
startDay := startDayFile.Read([]model.Category{}) // we don't need the categories for this
err = startDay.AddEvent(
&model.Event{
Expand Down Expand Up @@ -131,7 +131,7 @@ func (command *AddCommand) Execute(args []string) error {
current := dateIncrementer(date)

for !current.IsAfter(repeatTilDate) {
currentDayFile := filehandling.NewFileHandler(envData.BaseDirPath + "/days/" + current.ToString())
currentDayFile := storage.NewFileHandler(envData.BaseDirPath + "/days/" + current.ToString())
currentDay := currentDayFile.Read([]model.Category{}) // we don't need the categories for this
err = currentDay.AddEvent(
&model.Event{
Expand Down
Loading

0 comments on commit 08b6be2

Please sign in to comment.