Add --repeat flag for recurring reminders - #107
Open
rameshbaskaran wants to merge 2 commits into
Open
Conversation
reminders-cli previously had no way to create or edit recurring reminders, even though EKRecurrenceRule is public EventKit API and Reminders.app natively supports repeat rules. Adds: - Recurrence: ExpressibleByArgument parsing daily/weekly/monthly/yearly, optionally with an interval like '2-weeks' or '3-months' - 'reminders add ... --repeat <freq>' (requires --due-date, since EKReminder recurrence has no meaning without a due date) - 'reminders edit ... --repeat <freq> [--due-date <date>]' to add/replace recurrence on an existing reminder - recurrence rules are attached before the initial EKEventStore.save(), matching Apple's documented (if under-documented) requirement that addRecurrenceRule() calls after save() are silently dropped - recurrence surfaced in both plain and JSON output (show/show-all) - unit tests for the Recurrence parser
Swift's split(separator:) omits empty subsequences by default, so "-1-weeks".split(separator: "-") silently drops the leading empty segment and parses as interval=1 instead of being rejected. Guard against a leading '-' up front so negative intervals correctly return nil (invalid) instead of parsing as their positive counterpart. CI caught this: build succeeded, 21/22 tests passed, only testInvalidInterval failed on '-1-weeks' — this is the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
There's currently no way to create or edit a recurring reminder through this CLI, even though:
EKRecurrenceRuleis public EventKit API (not a private/undocumented framework)Users migrating recurring tasks from other tools (Todoist, etc.) into Reminders via this CLI have had to flatten everything into one-shot due dates.
Changes
Recurrence: ExpressibleByArgument(Sources/RemindersLibrary/Recurrence.swift) parsingdaily/weekly/monthly/yearly, plus interval forms like2-weeksor3-months.reminders add ... --repeat <freq>— requires--due-dateto also be set (a recurrence rule has no meaning without a due date onEKReminder).reminders edit ... --repeat <freq> [--due-date <date>]— adds/replaces recurrence on an existing reminder; if the reminder has no due date yet,--due-datemust be passed alongside--repeat.addRecurrenceRule()before the initialEKEventStore.save()— adding them after save silently fails to persist (undocumented but consistently reported behavior across EventKit).(repeats: weekly)) and JSON ("recurrence": "weekly") output forshow/show-all, so pre-existing recurring reminders (created via Reminders.app) now also report their recurrence.Recurrenceparser (Tests/RemindersTests/RecurrenceTests.swift).Testing
Built and manually verified end-to-end against a real local Reminders list:
Also verified
edit --repeatadds recurrence to an existing non-recurring reminder, and that pre-existing recurring reminders created via Reminders.app UI (e.g. daily/weekly ones already on my list) correctly show(repeats: ...)with the new encoder logic — confirming the JSON/plain output changes don't regress anything for reminders this tool didn't create.swift build -Xswiftc -warnings-as-errorspasses clean locally.swift testrequires a full Xcode toolchain (not available in my sandboxed environment, XCTest module missing from Command Line Tools only) — added tests should run fine under themacos-14+ Xcode 16.2 CI config already in.github/workflows/swift.yml.Scope
This intentionally covers frequency + interval only (not day-of-week sets, end conditions/count, etc.) to keep the CLI surface simple — matches the level of expressiveness most task-migration use cases need. Happy to extend if there's interest.