From 2bb7044aba025d2ae9641e254b175f8af0c129c1 Mon Sep 17 00:00:00 2001 From: Spirit of Light Date: Sat, 21 Nov 2026 10:53:06 -0500 Subject: [PATCH] Feat(tui): Skip this time, and a daily note's date for repeating tasks The desktop app has the task menu item Skip this time. It writes the next occurrence of a `@repeat:` task and keeps this occurrence as a cancelled record. The task menu of zn now has the same item, with the key `n`. It shows only for an open inline task with `@repeat:`. A check-off of a repeating task from the Tasks list, the board, Home or the calendar now counts from the date of its daily note, as on the desktop. This applies only when daily notes are on and their tasks take the note date. A `due:` on the line and a `due` in the frontmatter come first. After the roll, a notice gives the next date. The CLI and MCP do not change. They count from today, as the MCP of the desktop does. The roll goes through the backend, so it works for local and remote vaults. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0171pE1tFQspTuCEpf1xvQiH --- README.md | 3 + internal/cli/tasks_test.go | 59 ++++++ internal/tui/data.go | 18 ++ internal/tui/helpdata.go | 2 +- internal/tui/task_skip_test.go | 317 +++++++++++++++++++++++++++++ internal/tui/views_tasks.go | 82 +++++++- internal/vault/task_repeat_rule.go | 12 ++ 7 files changed, 484 insertions(+), 9 deletions(-) create mode 100644 internal/tui/task_skip_test.go create mode 100644 internal/vault/task_repeat_rule.go diff --git a/README.md b/README.md index 84c0712..152c660 100644 --- a/README.md +++ b/README.md @@ -604,6 +604,9 @@ reloads it afterwards. In Vim mode, `Ctrl+Z` suspends to the shell. note titles, `!priority`, `#tags` and `@fields`. `:filters` / `:savefilter` manage shared named queries. Prefix terminal operators with `where:`, for example `where: is:open due:today -meeting`. + A task with `@repeat:` in a daily note counts from the date of that note, + as in the desktop app. The menu item Skip this time (`n`) cancels one + occurrence and writes the next. The calendar has month, week and day views; `Esc` cycles them, and a start in `calendar` mode always opens the month grid. On a narrow terminal the month shows a compact grid with a count per day and the diff --git a/internal/cli/tasks_test.go b/internal/cli/tasks_test.go index 42cf912..2028073 100644 --- a/internal/cli/tasks_test.go +++ b/internal/cli/tasks_test.go @@ -8,6 +8,9 @@ import ( "slices" "strings" "testing" + "time" + + "github.com/ZenNotes/tui/internal/vault" ) // A `[-]` cancelled task is abandoned, so `zn task list` leaves it out by @@ -77,3 +80,59 @@ func TestTaskTogglePrintsWhereARecurringTaskWent(t *testing.T) { t.Fatalf("%q", data) } } + +// The CLI counts a recurring task from today, as the app's MCP does, even in a +// daily note: only the terminal app counts from the date of the note. The note +// is three days old, so a weekly step from its date differs from one from today +// on every day. +func TestTaskToggleCountsARecurringTaskFromTodayInADailyNote(t *testing.T) { + isolatedCLI(t) + root := t.TempDir() + // Read once before the command runs; a run that crosses midnight counts + // from the next day. + start := time.Now() + noteDate := vault.TodayISO(start.AddDate(0, 0, -3)) + rel := "Daily Notes/" + noteDate + ".md" + const body = "- [ ] water @repeat:7d\n" + files := map[string]string{ + ".zennotes/vault.json": `{"primaryNotesLocation":"root","dailyNotes":{"enabled":true}}`, + rel: body, + } + for name, text := range files { + abs := filepath.Join(root, filepath.FromSlash(name)) + if err := os.MkdirAll(filepath.Dir(abs), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(abs, []byte(text), 0o644); err != nil { + t.Fatal(err) + } + } + captureOutput(t, func() { + if code := Main([]string{"task", "toggle", rel + "#0", "--vault", root}); code != 0 { + t.Fatalf("exit %d", code) + } + }) + data, err := os.ReadFile(filepath.Join(root, filepath.FromSlash(rel))) + if err != nil { + t.Fatal(err) + } + roll := func(day time.Time, fallback string) string { + done, ok := vault.CompleteRecurringTaskAtIndex(body, 0, vault.DialectCLI, vault.RecurringOptions{Today: vault.TodayISO(day), FallbackDue: fallback}) + if !ok { + t.Fatal("the task does not repeat") + } + return done.Body + } + counted := false + for _, day := range []time.Time{start, start.AddDate(0, 0, 1)} { + if string(data) == roll(day, "") { + counted = true + } + if string(data) == roll(day, noteDate) { + t.Fatalf("note counts from the note date %s: %q", noteDate, data) + } + } + if !counted { + t.Fatalf("note = %q, want a roll from today", data) + } +} diff --git a/internal/tui/data.go b/internal/tui/data.go index 1e305cd..d7dbb47 100644 --- a/internal/tui/data.go +++ b/internal/tui/data.go @@ -252,6 +252,24 @@ func (a *App) dailyDueByPath() map[string]string { return out } +// dailyDueOfPath is the date of the daily note at path. It is empty when the +// note is not a daily note, or when the settings do not count a task from the +// date of its note. +func (a *App) dailyDueOfPath(path string) string { + if a.idx == nil || !a.idx.settings.DailyNotes.Enabled || !a.idx.settings.DailyNotes.TasksDueOnNoteDate { + return "" + } + n, ok := a.noteMeta(path) + if !ok || n.Folder != vault.FolderInbox { + return "" + } + _, sub := a.folderOfPath(n.Path) + if date, ok := periodic.DateOf(periodic.Daily, sub, n.Title, a.idx.settings, a.primaryAtRoot()); ok { + return date.Format("2006-01-02") + } + return "" +} + // displayTasks are the tasks the Tasks surfaces show: daily-note due // inference applied, archived notes retired unless the preference keeps them. func (a *App) displayTasks() []vault.Task { diff --git a/internal/tui/helpdata.go b/internal/tui/helpdata.go index 1703e91..68a839d 100644 --- a/internal/tui/helpdata.go +++ b/internal/tui/helpdata.go @@ -196,7 +196,7 @@ func helpLines(a *App, filter string) []string { "J K\tMove the task up or down inside its note (list in note order)", "O / :order\tList order: note order or priority (high first in each group); shared with the desktop's Order menu via tasks_list_order", "n f F A\tNew task in the daily note, filter, clear the filter, include archived", - "m\tTask menu (includes forward to today's daily note)", + "m\tTask menu (includes forward to today's daily note, and Skip this time for a task with @repeat:)", "Board: h l j k\tMove between columns and cards; H L move the card; g cycles the grouping", "Calendar: h j k l [ ] t\tMove days and months, t is today; Esc cycles month, week and day; Enter and Tab move focus to the day's tasks and the No-date strip; o opens the daily note", "Calendar task: T @\tMove the focused task to today; pick its due date from a menu", diff --git a/internal/tui/task_skip_test.go b/internal/tui/task_skip_test.go new file mode 100644 index 0000000..2efde89 --- /dev/null +++ b/internal/tui/task_skip_test.go @@ -0,0 +1,317 @@ +package tui + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "strings" + "sync" + "testing" + "time" + + "github.com/ZenNotes/tui/internal/backend" + "github.com/ZenNotes/tui/internal/vault" + "github.com/ZenNotes/tui/internal/vim" +) + +const ( + skipDailySettings = `{"primaryNotesLocation":"root","dailyNotes":{"enabled":true}}` + skipDailyOff = `{"primaryNotesLocation":"root","dailyNotes":{"enabled":true,"tasksDueOnNoteDate":false}}` + skipDailyPath = "Daily Notes/2026-11-18.md" +) + +// skipApp opens a vault with the given files and a fixed clock of 2026-11-25. +func skipApp(t *testing.T, files map[string]string) (*App, string) { + t.Helper() + calFixToday(t, calDate(2026, time.November, 25)) + t.Setenv("ZENNOTES_CONFIG_DIR", t.TempDir()) + root := t.TempDir() + for rel, body := range files { + abs := filepath.Join(root, filepath.FromSlash(rel)) + if err := os.MkdirAll(filepath.Dir(abs), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(abs, []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + a := newSessionParityApp(t, root) + loaded := a.loadTasksCmd()().(tasksLoadedMsg) + if loaded.err != nil { + t.Fatal(loaded.err) + } + a.idx.tasks = loaded.tasks + a.width, a.height, a.ready = 120, 40, true + a.layout() + return a, root +} + +func skipTaskOf(t *testing.T, a *App, path string) vault.Task { + t.Helper() + for _, task := range a.displayTasks() { + if task.SourcePath == path && task.TaskIndex == 0 { + return task + } + } + t.Fatalf("no task in %s", path) + return vault.Task{} +} + +func skipItems(a *App, task vault.Task) []menuItem { + a.overlay = nil + a.taskMenu(task) + return a.overlay.(*menu).items +} + +func skipItem(items []menuItem) (menuItem, bool) { + for _, it := range items { + if it.label == "Skip this time" { + return it, true + } + } + return menuItem{}, false +} + +func skipRead(t *testing.T, root, rel string) string { + t.Helper() + data, err := os.ReadFile(filepath.Join(root, filepath.FromSlash(rel))) + if err != nil { + t.Fatal(err) + } + return string(data) +} + +func TestTaskMenuOffersSkipThisTimeOnlyForAnOpenRepeatingInlineTask(t *testing.T) { + a, _ := skipApp(t, map[string]string{"n.md": "- [ ] water @repeat:monthly due:2026-11-01\n"}) + open := skipTaskOf(t, a, "n.md") + for _, tc := range []struct { + name string + edit func(*vault.Task) + want bool + }{ + {"open repeating", func(*vault.Task) {}, true}, + {"no repeat", func(k *vault.Task) { k.RawText = "- [ ] water due:2026-11-01" }, false}, + {"rule that does not parse", func(k *vault.Task) { k.RawText = "- [ ] water @repeat:sometimes" }, false}, + {"task note", func(k *vault.Task) { k.Kind = "file" }, false}, + {"checked", func(k *vault.Task) { k.Checked = true }, false}, + {"cancelled", func(k *vault.Task) { k.Cancelled = true }, false}, + {"forwarded", func(k *vault.Task) { k.Forwarded = true }, false}, + } { + task := open + tc.edit(&task) + if _, got := skipItem(skipItems(a, task)); got != tc.want { + t.Errorf("%s: Skip this time shown = %v, want %v", tc.name, got, tc.want) + } + } + keys := map[string]bool{} + for _, it := range skipItems(a, open) { + if it.sep { + continue + } + if keys[it.key] { + t.Errorf("menu key %q is used twice", it.key) + } + keys[it.key] = true + if it.key == "j" || it.key == "k" || it.key == "q" { + t.Errorf("menu key %q moves the menu or closes it", it.key) + } + } +} + +func TestSkipThisTimeWritesACancelledRecordAndNamesTheNextDay(t *testing.T) { + a, root := skipApp(t, map[string]string{"n.md": "- [ ] water @repeat:monthly due:2026-11-01\n"}) + item, ok := skipItem(skipItems(a, skipTaskOf(t, a, "n.md"))) + if !ok { + t.Fatal("the task menu has no Skip this time") + } + item.run(a) + want := "- [ ] water @repeat:monthly due:2026-12-01\n- [-] water due:2026-11-01\n" + if got := skipRead(t, root, "n.md"); got != want { + t.Fatalf("note after skip:\n%s\nwant:\n%s", got, want) + } + if a.message != "Skipped. Next: 2026-12-01" { + t.Fatalf("notice = %q", a.message) + } +} + +func TestCheckOffFromTheTasksViewCountsFromTheDailyNoteDate(t *testing.T) { + const task = "- [ ] water @repeat:monthly\n" + for _, tc := range []struct { + name string + files map[string]string + path string + want string + note string + }{ + { + "daily note, setting on", + map[string]string{".zennotes/vault.json": skipDailySettings, skipDailyPath: task}, + skipDailyPath, + "- [ ] water @repeat:monthly due:2026-12-18\n- [x] water\n", + "Next: 2026-12-18", + }, + { + "daily note, setting off", + map[string]string{".zennotes/vault.json": skipDailyOff, skipDailyPath: task}, + skipDailyPath, + "- [ ] water @repeat:monthly due:2026-12-25\n- [x] water\n", + "Next: 2026-12-25", + }, + { + "plain note", + map[string]string{".zennotes/vault.json": skipDailySettings, "n.md": task}, + "n.md", + "- [ ] water @repeat:monthly due:2026-12-25\n- [x] water\n", + "Next: 2026-12-25", + }, + { + "line due wins", + map[string]string{".zennotes/vault.json": skipDailySettings, skipDailyPath: "- [ ] water @repeat:monthly due:2026-11-04\n"}, + skipDailyPath, + "- [ ] water @repeat:monthly due:2026-12-04\n- [x] water due:2026-11-04\n", + "Next: 2026-12-04", + }, + { + "frontmatter due wins", + map[string]string{".zennotes/vault.json": skipDailySettings, skipDailyPath: "---\ndue: 2026-11-04\n---\n" + task}, + skipDailyPath, + "---\ndue: 2026-11-04\n---\n- [ ] water @repeat:monthly due:2026-12-04\n- [x] water\n", + "Next: 2026-12-04", + }, + } { + t.Run(tc.name, func(t *testing.T) { + a, root := skipApp(t, tc.files) + a.toggleTask(skipTaskOf(t, a, tc.path)) + if got := skipRead(t, root, tc.path); got != tc.want { + t.Fatalf("note after check-off:\n%s\nwant:\n%s", got, tc.want) + } + if a.message != tc.note { + t.Fatalf("notice = %q, want %q", a.message, tc.note) + } + }) + } +} + +func TestCheckOffOfATaskWithAnInferredDuePassesThatDue(t *testing.T) { + a, root := skipApp(t, map[string]string{"n.md": "- [ ] water @repeat:monthly\n"}) + task := skipTaskOf(t, a, "n.md") + task.Due, task.DueInferred = "2026-11-10", true + a.toggleTask(task) + want := "- [ ] water @repeat:monthly due:2026-12-10\n- [x] water\n" + if got := skipRead(t, root, "n.md"); got != want { + t.Fatalf("note after check-off:\n%s\nwant:\n%s", got, want) + } +} + +func TestBoardMoveToDoneAndMenuToggleCountFromTheDailyNoteDate(t *testing.T) { + files := map[string]string{".zennotes/vault.json": skipDailySettings, skipDailyPath: "- [ ] water @repeat:monthly\n"} + want := "- [ ] water @repeat:monthly due:2026-12-18\n- [x] water\n" + a, root := skipApp(t, files) + a.setTaskStatusColumn(skipTaskOf(t, a, skipDailyPath), "done") + if got := skipRead(t, root, skipDailyPath); got != want { + t.Fatalf("after a board move to Done:\n%s", got) + } + a, root = skipApp(t, files) + for _, it := range skipItems(a, skipTaskOf(t, a, skipDailyPath)) { + if it.label == "Toggle done" { + it.run(a) + } + } + if got := skipRead(t, root, skipDailyPath); got != want { + t.Fatalf("after the menu Toggle done:\n%s", got) + } +} + +func TestOrdinaryTaskStillTogglesWithoutANotice(t *testing.T) { + a, root := skipApp(t, map[string]string{"n.md": "- [ ] water\n"}) + a.toggleTask(skipTaskOf(t, a, "n.md")) + if got := skipRead(t, root, "n.md"); got != "- [x] water\n" { + t.Fatalf("note = %q", got) + } + if a.message != "" { + t.Fatalf("notice = %q", a.message) + } +} + +// remoteNoteServer is a server with one note that serves reads and writes. +func remoteNoteServer(t *testing.T, path, body string) (*httptest.Server, func() string) { + t.Helper() + var mu sync.Mutex + current := body + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mu.Lock() + defer mu.Unlock() + w.Header().Set("Content-Type", "application/json") + switch r.URL.Path { + case "/api/notes/read": + _ = json.NewEncoder(w).Encode(vault.NoteContent{NoteMeta: vault.NoteMeta{Path: path, Title: "n"}, Body: current}) + case "/api/notes/write": + var in struct{ Path, Body string } + _ = json.NewDecoder(r.Body).Decode(&in) + current = in.Body + _ = json.NewEncoder(w).Encode(vault.NoteMeta{Path: path, Title: "n"}) + default: + http.NotFound(w, r) + } + })) + t.Cleanup(srv.Close) + return srv, func() string { mu.Lock(); defer mu.Unlock(); return current } +} + +func TestSkipAndCheckOffWorkOnARemoteVault(t *testing.T) { + for _, skip := range []bool{true, false} { + a, _ := skipApp(t, map[string]string{"n.md": "- [ ] x\n"}) + srv, stored := remoteNoteServer(t, "n.md", "- [ ] water @repeat:monthly\n") + target := backend.Target{Kind: backend.KindRemote, BaseURL: srv.URL} + b, err := backend.New(target, backend.Options{}) + if err != nil { + t.Fatal(err) + } + a.backend, a.opts.Backend, a.opts.Target = b, b, target + task := vault.Task{SourcePath: "n.md", TaskIndex: 0, Content: "water", RawText: "- [ ] water @repeat:monthly", Due: "2026-11-18", DueInferred: true} + want, notice := "- [ ] water @repeat:monthly due:2026-12-18\n- [x] water\n", "Next: 2026-12-18" + if skip { + for _, it := range skipItems(a, task) { + if it.label == "Skip this time" { + it.run(a) + } + } + want, notice = strings.Replace(want, "[x]", "[-]", 1), "Skipped. "+notice + } else { + a.toggleTask(task) + } + if got := stored(); got != want { + t.Errorf("skip=%v: remote note:\n%s\nwant:\n%s", skip, got, want) + } + if a.message != notice { + t.Errorf("skip=%v: notice = %q, want %q", skip, a.message, notice) + } + } +} + +// A roll writes lines above the task, so a cursor on or below the task moves +// down with the text, and a cursor above it stays. +func TestRollKeepsTheCursorOnItsLineInAnOpenNote(t *testing.T) { + const note = "intro\n- [ ] water @repeat:monthly due:2026-11-01\nafter\n" + for _, tc := range []struct { + name string + line, want int + }{ + {"above the task", 0, 0}, + {"on the task", 1, 2}, + {"below the task", 2, 3}, + } { + t.Run(tc.name, func(t *testing.T) { + a, _ := skipApp(t, map[string]string{"n.md": note}) + a.openNote("n.md", true) + buf := a.buffers["n.md"] + buf.ed.SetCursor(vim.Pos{Line: tc.line}) + a.rollRecurringTask(skipTaskOf(t, a, "n.md"), false) + if got := buf.ed.Cursor().Line; got != tc.want { + t.Fatalf("cursor line = %d, want %d\n%s", got, tc.want, buf.ed.Text()) + } + }) + } +} diff --git a/internal/tui/views_tasks.go b/internal/tui/views_tasks.go index 9ba780c..851fe44 100644 --- a/internal/tui/views_tasks.go +++ b/internal/tui/views_tasks.go @@ -1232,6 +1232,9 @@ func (a *App) openTaskSource(t vault.Task) { } func (a *App) toggleTask(t vault.Task) { + if a.rollRecurringTask(t, false) { + return + } err := a.mutateNote(t.SourcePath, func(body string) (string, bool) { if t.Kind == "file" { return vault.ToggleFileTaskInBody(body, t.Checked, time.Now()), true @@ -1322,6 +1325,9 @@ func (a *App) setTaskField(t vault.Task, key, value string) { // setTaskStatusColumn changes scheduling/checkbox state independently of custom fields. func (a *App) setTaskStatusColumn(t vault.Task, status string) { + if status == "done" && a.rollRecurringTask(t, false) { + return + } a.editTaskLine(t, func(body string) string { checked := func(v bool) { if t.Kind == "file" { @@ -1482,20 +1488,80 @@ func (a *App) taskFieldPrompt(t vault.Task) { } func (a *App) taskMenu(t vault.Task) { - a.showMenu(truncateCells(t.Content, 40), []menuItem{ + items := []menuItem{ {key: "o", label: "Open note", run: func(a *App) { a.openTaskSource(t) }}, {key: "x", label: "Toggle done", run: func(a *App) { a.toggleTask(t) }}, {key: "/", label: "Toggle in progress", run: func(a *App) { a.setTaskInProgress(t, !t.InProgress) }}, {key: "w", label: "Toggle waiting", run: func(a *App) { a.setTaskWaiting(t, !t.Waiting) }}, {key: "c", label: "Toggle cancelled", run: func(a *App) { a.setTaskCancelled(t, !t.Cancelled) }}, - {sep: true}, - {key: "p", label: "Priority", run: func(a *App) { a.taskPriorityMenu(t) }}, - {key: "d", label: "Due date", run: func(a *App) { a.taskDuePrompt(t) }}, - {key: "e", label: "Edit text", run: func(a *App) { a.taskTextPrompt(t) }}, - {key: "s", label: "Set field", run: func(a *App) { a.taskFieldPrompt(t) }}, - {key: "f", label: "Forward to today's daily note", run: func(a *App) { a.forwardTask(t) }}, - {key: "y", label: "Copy line", run: func(a *App) { a.copyText(t.RawText) }}, + } + if canRollTask(t) && vault.HasValidRepeatRule(t.RawText) && !t.Cancelled && !t.Forwarded { + // The keys j, k and q move or close the menu, so the item cannot use k. + items = append(items, menuItem{key: "n", label: "Skip this time", run: func(a *App) { a.rollRecurringTask(t, true) }}) + } + a.showMenu(truncateCells(t.Content, 40), append(items, + menuItem{sep: true}, + menuItem{key: "p", label: "Priority", run: func(a *App) { a.taskPriorityMenu(t) }}, + menuItem{key: "d", label: "Due date", run: func(a *App) { a.taskDuePrompt(t) }}, + menuItem{key: "e", label: "Edit text", run: func(a *App) { a.taskTextPrompt(t) }}, + menuItem{key: "s", label: "Set field", run: func(a *App) { a.taskFieldPrompt(t) }}, + menuItem{key: "f", label: "Forward to today's daily note", run: func(a *App) { a.forwardTask(t) }}, + menuItem{key: "y", label: "Copy line", run: func(a *App) { a.copyText(t.RawText) }}, + )) +} + +// canRollTask says whether a check-off writes the next occurrence of the task: +// an open inline task with `@repeat:`. +func canRollTask(t vault.Task) bool { + return t.Kind != "file" && !t.Checked && strings.Contains(strings.ToLower(t.RawText), "@repeat:") +} + +// rollRecurringTask checks off, or with skip skips, an open repeating task: +// the next occurrence goes above it. It counts from the date of the daily note +// that holds the task, as the app does, and not from today. It returns false +// when the task does not repeat, and the caller toggles it as usual. +func (a *App) rollRecurringTask(t vault.Task, skip bool) bool { + if !canRollTask(t) { + return false + } + opts := vault.RecurringOptions{Today: vault.TodayISO(calendarNow()), FallbackDue: a.recurrenceBase(t), Skip: skip} + var done vault.RecurringCompletion + rolled := false + err := a.mutateNote(t.SourcePath, func(body string) (string, bool) { + done, rolled = vault.CompleteRecurringTaskAtIndex(body, t.TaskIndex, vault.DialectApp, opts) + return done.Body, rolled }) + if err != nil { + a.notifyError(err.Error()) + return true + } + if !rolled { + return false + } + if buf := a.buffers[t.SourcePath]; buf != nil { + // The lines went in above the task, so a cursor on or below it moves down. + if cur := buf.ed.Cursor(); cur.Line >= t.LineNumber { + cur.Line += done.InsertedLines + buf.ed.SetCursor(cur) + } + } + notice := "Next: " + done.NextDue + if skip { + notice = "Skipped. " + notice + } + a.notify(notice) + a.afterTaskChange() + return true +} + +// recurrenceBase is the date a repeating task counts from when it has no +// `due:` of its own: the due the Tasks surfaces inferred, else the date of its +// daily note. +func (a *App) recurrenceBase(t vault.Task) string { + if t.DueInferred { + return t.Due + } + return a.dailyDueOfPath(t.SourcePath) } // forwardTask moves an open task (with its subtasks) to today's daily note, diff --git a/internal/vault/task_repeat_rule.go b/internal/vault/task_repeat_rule.go new file mode 100644 index 0000000..c7b9ab3 --- /dev/null +++ b/internal/vault/task_repeat_rule.go @@ -0,0 +1,12 @@ +package vault + +// HasValidRepeatRule says whether text carries an `@repeat:` field whose rule +// reads. A task with any other rule is an ordinary task. +func HasValidRepeatRule(text string) bool { + field := repeatFieldRe.FindStringSubmatch(text) + if field == nil { + return false + } + _, ok := parseRepeatRule(field[1]) + return ok +}