diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-19 23:50:10 +0300 |
|---|---|---|
| committer | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-19 23:50:10 +0300 |
| commit | d76f1e1e088b84c1ef3742f8f9cc855a8433ed44 (patch) | |
| tree | 07317758546f529fa7bdb793d40c1b812ede6854 /cmd | |
| parent | 07527d6cc3e3d9438977d780a2687851d096fba1 (diff) | |
Add Charm bubble tea UI
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/tasksamurai/main.go | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/cmd/tasksamurai/main.go b/cmd/tasksamurai/main.go index 492cdaf..95aef13 100644 --- a/cmd/tasksamurai/main.go +++ b/cmd/tasksamurai/main.go @@ -2,10 +2,46 @@ package main import ( "fmt" + "os" "tasksamurai/internal" + "tasksamurai/internal/task" + "tasksamurai/internal/ui" + + "github.com/charmbracelet/bubbles/list" + tea "github.com/charmbracelet/bubbletea" ) func main() { - fmt.Println("tasksamurai version", internal.Version) + tasks, err := task.Export() + if err != nil { + fmt.Fprintln(os.Stderr, "failed to export tasks:", err) + os.Exit(1) + } + + var items []list.Item + for _, t := range tasks { + if t.Status != "completed" { + items = append(items, taskItem{t}) + } + } + + delegate := list.NewDefaultDelegate() + l := list.New(items, delegate, 0, 0) + l.Title = fmt.Sprintf("tasksamurai %s", internal.Version) + l.SetShowStatusBar(false) + l.SetFilteringEnabled(false) + m := ui.New(l) + + p := tea.NewProgram(&m) + if _, err := p.Run(); err != nil { + fmt.Fprintln(os.Stderr, "error running ui:", err) + os.Exit(1) + } } + +type taskItem struct{ t task.Task } + +func (i taskItem) Title() string { return i.t.Description } +func (i taskItem) Description() string { return "" } +func (i taskItem) FilterValue() string { return i.t.Description } |
