1 Commits

Author SHA1 Message Date
Martin Pander
6f77b03555 WIP 2026-05-09 23:41:46 +02:00
2 changed files with 2 additions and 82 deletions

5
.gitignore vendored
View File

@@ -1,8 +1,7 @@
.DS_Store
test/taskchampion.sqlite3
/tasksquire
tasksquire
test/*.sqlite3*
result
/main
main
__debug*

View File

@@ -1,79 +0,0 @@
package main
import (
"context"
"log"
"log/slog"
"os"
"path/filepath"
"tasksquire/internal/common"
"tasksquire/internal/pages"
"tasksquire/internal/taskwarrior"
"tasksquire/internal/timewarrior"
//
tea "charm.land/bubbletea/v2"
)
func findTaskrc() string {
home, _ := os.UserHomeDir()
cwd, _ := os.Getwd()
searchPaths := []string{
filepath.Join(cwd, ".taskrc"),
os.Getenv("TASKRC"),
// TODO: use xdg config home envvar
filepath.Join(home, ".config/task/taskrc"),
filepath.Join(home, ".taskrc"),
}
for _, path := range searchPaths {
if path == "" {
continue
}
if _, err := os.Stat(path); err == nil {
return path
}
}
log.Fatal("Could not find taskrc in ENV, project root, or home directory")
return ""
}
func main() {
logfile, err := os.OpenFile("/tmp/tasksquire.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatalf("failed to open log file: %v", err)
}
defer logfile.Close()
handler := slog.NewTextHandler(logfile, &slog.HandlerOptions{})
slog.SetDefault(slog.New(handler))
taskrcPath := findTaskrc()
slog.Info(taskrcPath)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
taskw := taskwarrior.NewTaskwarriorInterop(ctx, taskrcPath)
if taskw == nil {
log.Fatal("Failed to initialize Taskwarrior. Please check your Taskwarrior installation and taskrc file.")
}
timew := timewarrior.NewTimewarriorInterop(ctx, "")
if timew == nil {
log.Fatal("Failed to initialize Timewarrior. Please check your Timewarrior installation and timewarrior.cfg file.")
}
common := common.NewCommon(ctx, taskw, timew)
m := pages.NewMainPage(common)
// slog.Info(m)
if _, err := tea.NewProgram(m).Run(); err != nil {
log.Fatal("Error running program:", err)
os.Exit(1)
}
}