summaryrefslogtreecommitdiff
path: root/internal/app/tag_commands.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/app/tag_commands.go')
-rw-r--r--internal/app/tag_commands.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/app/tag_commands.go b/internal/app/tag_commands.go
new file mode 100644
index 0000000..c83fab7
--- /dev/null
+++ b/internal/app/tag_commands.go
@@ -0,0 +1,20 @@
+package app
+
+import tea "github.com/charmbracelet/bubbletea"
+
+import "yoga/internal/tags"
+
+func saveTagsCmd(path string, entries []string) tea.Cmd {
+ // Copy slice to avoid accidental mutation after scheduling command.
+ values := append([]string{}, entries...)
+ return func() tea.Msg {
+ if err := tags.Save(path, values); err != nil {
+ return tagsSavedMsg{path: path, err: err}
+ }
+ sanitized, err := tags.Load(path)
+ if err != nil {
+ return tagsSavedMsg{path: path, err: err}
+ }
+ return tagsSavedMsg{path: path, tags: sanitized}
+ }
+}