Initial Commit

This commit is contained in:
steven carpenter 2025-07-27 15:11:43 -04:00
commit 87a522daab
22 changed files with 1555 additions and 0 deletions

46
tui/run.go Normal file
View file

@ -0,0 +1,46 @@
package tui
import (
"fmt"
"time"
"git.skdevstudios.com/SK-Development-Studios/go-cal-tui/internal/storage"
"git.skdevstudios.com/SK-Development-Studios/go-cal-tui/internal/logger"
tea "github.com/charmbracelet/bubbletea"
)
//Table definition constants
const (
numRows = 6
numCols = 7
cellW = 10
cellH = 1
)
func Run() error {
if err := storage.InitDB("data"); err != nil {
logOut := fmt.Errorf("Failed to initalize BadgerDB: %w",err)
logger.Log.Fatal(logOut)
}
defer storage.CloseDB()
// Get the current datetime
now := time.Now()
// Set the start date used for opening the current month instead of 1/1/1970
start := time.Date(now.Year(), now.Month(), 1,0,0,0,0, time.UTC)
// This gets the weekday of the first of the month so that we have the correct day with the correct date
offset := int(start.Weekday())
p := tea.NewProgram(model{
year: now.Year(),
monthIndex: int(now.Month()) - 1,
cursorRow: offset / numCols,
cursorCol: offset % numCols,
startOffset: offset,
mode: monthView,
})
_, err := p.Run()
return err
}