Skip to content

Commit

Permalink
✨ Missing config file is no longer fatal.
Browse files Browse the repository at this point in the history
  • Loading branch information
porridge committed Apr 15, 2023
1 parent 0dbdc15 commit 7617004
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func main() {
return
}
categories, err := config.Read(*configFile)
if err != nil {
if os.IsNotExist(err) {
log.Printf("Could not read config file %q, cannot categorize events: %s", *configFile, err)
} else if err != nil {
log.Fatalf("Could not read config file %q: %s", *configFile, err)
}

Expand All @@ -106,9 +108,10 @@ func analyzeAndPrint(events []*calendar.Event, categories []*core.Category, deci
value := formatDayTotal(decimalOutput, dayTotals[day])
fmt.Printf("%v: %s\n", day, value)
}
if len(categories) > 0 {
fmt.Println("Time spent per category:")
if len(categories) == 0 {
return unrecognized
}
fmt.Println("Time spent per category:")
for _, category := range categories {
catName := category.Name
val := categoryTotals[catName]
Expand Down

0 comments on commit 7617004

Please sign in to comment.