Skip to content

Commit

Permalink
Added unlogged todo counts in log command.
Browse files Browse the repository at this point in the history
  • Loading branch information
wakatara committed Oct 23, 2023
1 parent 2c12720 commit 19af9f1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions harsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Entries map[DailyHabit]Outcome
type Harsh struct {
Habits []Habit
MaxHabitNameLength int
Entries *Entries
Entries *Entries
FirstRecords map[Habit]civil.Date
}

Expand All @@ -60,7 +60,7 @@ func main() {
Name: "Harsh",
Usage: "habit tracking for geeks",
Description: "A simple, minimalist CLI for tracking and understanding habits.",
Version: "0.8.29",
Version: "0.8.30",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-color",
Expand Down Expand Up @@ -121,6 +121,7 @@ func main() {
to := civil.DateOf(time.Now())
from := to.AddDays(-100)
consistency := map[string][]string{}
undone := harsh.getTodos(to, 0)

sparkline := harsh.buildSpark(from, to)
fmt.Printf("%*v", harsh.MaxHabitNameLength, "")
Expand All @@ -139,8 +140,15 @@ func main() {
fmt.Printf("\n")
}

undone_num := strconv.Itoa(len(undone[to.String()]))

scoring := fmt.Sprintf("%.1f", harsh.score(civil.DateOf(time.Now()).AddDays(-1)))
fmt.Printf("\n" + "Yesterday's Score: " + scoring + "%%\n")
fmt.Printf("\n" + "Yesterday's Score: ")
fmt.Printf("%9v", scoring)
fmt.Printf("%%\n")
fmt.Printf("Today's unlogged todos: ")
fmt.Printf("%2v", undone_num)
fmt.Printf("\n")

return nil
},
Expand Down Expand Up @@ -289,7 +297,7 @@ func (h *Harsh) askHabits() {
}

func (e *Entries) firstRecords(from civil.Date, to civil.Date, habits []Habit) map[Habit]civil.Date {
firstRecords := map[Habit]civil.Date{}
firstRecords := map[Habit]civil.Date{}
for dt := to; !dt.Before(from); dt = dt.AddDays(-1) {
for _, habit := range habits {
if _, ok := (*e)[DailyHabit{Day: dt, Habit: habit.Name}]; ok {
Expand Down

0 comments on commit 19af9f1

Please sign in to comment.