summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-19 23:50:26 +0300
committerGitHub <noreply@github.com>2025-06-19 23:50:26 +0300
commitbf39c17221d1df1815c9cd78fa33b144c9d5dfb6 (patch)
tree6feb76e083b948beeb92c2b17ccf4c791db5eff2 /cmd
parent9f784dee3c132da890c22e1477fb2e41047a74e8 (diff)
parentd76f1e1e088b84c1ef3742f8f9cc855a8433ed44 (diff)
Merge pull request #4 from snonux/codex/add-basic-ui-with-charm.sh-for-tasks
Add Charm UI for listing tasks
Diffstat (limited to 'cmd')
-rw-r--r--cmd/tasksamurai/main.go38
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 }